Skip to content

fix(website): hand redaction-card focus over only from its opener - #16169

Merged
iamwhatever merged 2 commits into
mainfrom
fix/redaction-card-focus-handoff
Oct 4, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
fix/redaction-card-focus-handoff

Conversation

@Zedmor

@Zedmor Zedmor commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #16588

Problem / Motivation

Goal: Opening a redaction card no longer steals focus from a control the user moved to while the card was revealing.

A revealed redaction card (blocked link or credential) focused itself REVEAL_MS after mounting, whatever held focus by then. If the user opened another popover during the reveal, such as the composer's goal popup, the card took focus and that popover closed.

Why it matters

A fast click right after opening a card dismissed whatever the user had just opened, and keyboard users lost their place.

Not a goal

  • Any change to card content, layout or the reveal animation.
  • Focus behaviour of other popovers.

What changed (motivation → approach → change)

The delayed focus ignored who opened the card → the provider already tracks the opener in triggerRef; it is now exposed through the redaction context, and CardShell hands focus over only when the card is still the open one and its opener still holds focus. A card closed during its exit animation, or superseded by another block, no longer takes focus. A focused Cancel in the Open-once confirmation keeps focus as well.

Split out of #14089, where it rode along with the goal feature; the reviews there asked for independent corrections to land separately.

Backwards compatibility

Compatible: the context gains one field; no prop, route or stored value changes.

Tests

MarkdownRenderer.blockedLink.test.tsx adds a reveal focus ownership suite: focus reaches the card from either opener and returns on Escape; a control reached during the reveal keeps focus, including one focused in a layout effect; the Open-once Cancel keeps focus; a closed card in its exit animation is not focused; opening a second block cancels the first handoff and focuses the new card. 47 tests across the redaction test files pass; tsc and ESLint are clean.

Manual verification

N/A — the suite drives the timer and focus order directly with fake timers.

Screenshots / video

Why no screenshot: only the timing of a focus handoff changes; nothing rendered differs.

Related Issues

Split from #14089.

Pattern harvest

Rule candidate: review-prompt
Pattern: a delayed focus() that does not check the element that held focus when it was scheduled.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@Zedmor
Zedmor requested a review from a team October 2, 2026 15:07
@Zedmor
Zedmor requested a review from a team as a code owner October 2, 2026 15:07
@Zedmor
Zedmor requested a review from iamwhatever October 2, 2026 15:07
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 7a0f925aed4e48708820a422091cdf2b40dc36a3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Check in a real browser, Safari included, that the card still takes focus after its reveal and that Escape returns it to the opener; the tests run in jsdom.

[UX-REVIEWED] 7a0f925

Description read

[DESCRIPTION-READ] ef9422c69fb5441a3f28744de2ec9259ec795780e2c5afd54dd58fa19f38a5ce

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7a0f925aed4e48708820a422091cdf2b40dc36a3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check in real Safari or Firefox on macOS that a mouse click still lands focus on the card. jsdom only simulates focus staying on the body with blur().

[DESIGN-REVIEWED] 7a0f925

Description read

[DESCRIPTION-READ] 93a390f1a12acff952a0131097c1db474afe8d0f6d6202748190d960d036cee6

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7a0f925aed4e48708820a422091cdf2b40dc36a3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7a0f925

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7a0f925aed4e48708820a422091cdf2b40dc36a3: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7a0f925aed4e48708820a422091cdf2b40dc36a3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check in a real Safari or Firefox on macOS that a mouse click still hands focus to the card; the jsdom test only fakes focus staying on the body.

What this change ships

Inventory (6 items) — 6 justified

Intent: stop a redaction card's delayed self-focus from taking focus away from a control the user moved to while the card was revealing. This is a FIX.

  1. A control or popover the user focuses during the card's reveal keeps focus — justified
  2. The Open-once confirmation's Cancel keeps focus during the reveal — justified
  3. A card closed mid-reveal, or replaced by another card, no longer takes focus when its exit animation ends — justified
  4. A click that left focus on the body, or a held card reopened after its reply remounts, still focuses the card — justified
  5. The redaction context now exposes the opener ref it already tracked, read only by CardShell — justified
  6. A dashboard spec paragraph describes the focus handoff, updated in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] 7a0f925

Description read

[DESCRIPTION-READ] 23f1fa8a5cf44aafeaee359f6796e3caa10d5dcfbaeefc603a735e0ecd02c625

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

Zedmor pushed a commit that referenced this pull request Oct 2, 2026
The ps-column arguments, the redaction-card focus handoff and the ten
test-fixture isolation repairs share no cause with goals. They now land
on their own as #16168, #16169 and #16170, so reverting this feature no
longer reverts them.
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7a0f925aed4e48708820a422091cdf2b40dc36a3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7a0f925

Verdict parsed from the review's SHA-scoped output markers for commit 7a0f925aed4e48708820a422091cdf2b40dc36a3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7a0f925aed4e48708820a422091cdf2b40dc36a3: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 2, 2026
@Zedmor

Zedmor commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 31ef7ae: the flagged test/test_issue_radar_crew_runtime.py:364 is not in this PR, which changes only RedactionCards.tsx, its test and one spec paragraph; that holder thread came from main (#16102) through the merge ref.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@Zedmor marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 31ef7aec70e4be34081fd6c97efd678de90ee46c.

the flagged test/test_issue_radar_crew_runtime.py:364 is not in this PR, which changes only RedactionCards.tsx, its test and one spec paragraph; that holder thread came from main (#16102) through the merge ref.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 2, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix for the cases it targets, and the superseded-card, exit-animation and Cancel-focus tests are solid. But requiring activeElement === opener also skips the handoff when focus is nowhere: after a mouse click on Safari, iOS and Firefox-macOS (buttons do not take focus), and on the allow-hold remount where triggerRef is null. Both used to focus the card and now leave it unannounced to screen readers. Suggested fix: hand focus over when activeElement is the opener, null or document.body, and skip only when another element really holds focus. Please add tests for a body-focused click and for the hold remount.

Akim Akimov added 2 commits October 3, 2026 18:31
A revealed card focused itself REVEAL_MS after mount, whatever held
focus by then. A control the user reached during the reveal -- another
popover such as the composer's goal popup -- lost focus to the card and
closed. The delayed handoff now runs only while the card is the open
one and its opener still holds focus, so a card closed during its exit
animation, or superseded by another block, no longer takes focus.

Split out of #14089, where it rode along with the goal feature.
The focus rule this pull request implements belongs in the frontend
section of learn-cron-dashboard.md, which #14089 carried for it before
the split.
@Zedmor
Zedmor force-pushed the fix/redaction-card-focus-handoff branch from 31ef7ae to 7a0f925 Compare October 3, 2026 18:32
@Zedmor

Zedmor commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@iamwhatever thanks, addressed in 78dfad7, with the spec in 7a0f925. The handoff now runs when focus is still on the opener, on nothing, or on document.body, and is skipped only when another control holds focus. It no longer bails out when triggerRef is null, so the allow-hold remount focuses its card as well. Superseding, closing and exit animations still cancel the timer through openId.

New tests, both of which fail on the previous revision:

  • hands focus to the card when the click left focus on the body: a click that leaves focus on the body.
  • announces a held card that reopens when its reply remounts without an opener: the hold remount with no opener.

The existing superseded-card, exit-animation, Cancel-focus and moved-focus tests still pass (39/39).

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 3, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 3, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 7a0f925; my point is fixed. The handoff now proceeds when activeElement is the opener, null or document.body, and skips only when another control really took focus; a null triggerRef (held card on remount) no longer returns early. New tests cover a click that leaves focus on the body (fake timers, REVEAL_MS) and a held card that reopens on remount with no opener, and both fail against the old activeElement === trigger check. The doc paragraph matches. Clearing my request.

@iamwhatever
iamwhatever enabled auto-merge (squash) October 4, 2026 22:36
@iamwhatever
iamwhatever merged commit cb7865e into main Oct 4, 2026
104 of 108 checks passed
@iamwhatever
iamwhatever deleted the fix/redaction-card-focus-handoff branch October 4, 2026 22:36
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redaction details cards take focus from whatever the user moved to during the reveal

2 participants