Repository navigation
fix(website): hand redaction-card focus over only from its opener - #16169
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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 [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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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 shipsInventory (6 items) — 6 justifiedIntent: 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.
[FIRST-PRINCIPLES-REVIEWED] 7a0f925 Description read[DESCRIPTION-READ] 23f1fa8a5cf44aafeaee359f6796e3caa10d5dcfbaeefc603a735e0ecd02c625 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Human judgment recorded@Zedmor marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
iamwhatever
left a comment
There was a problem hiding this comment.
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.
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.
31ef7ae to
7a0f925
Compare
|
@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 New tests, both of which fail on the previous revision:
The existing superseded-card, exit-animation, Cancel-focus and moved-focus tests still pass (39/39). |
iamwhatever
left a comment
There was a problem hiding this comment.
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.
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_MSafter 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
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, andCardShellhands 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.tsxadds areveal focus ownershipsuite: 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;tscand 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