Repository navigation
feat(a11y): put the remaining ten dialogs on the focus contract - #710
Merged
Merged
Conversation
All seventeen are now on the shared Modal, so every dialog in the app traps
focus, takes focus when it opens, closes on Escape, returns focus to whatever
opened it, and announces itself as a modal dialog.
These ten were the ones with logic of their own, which is why they were left
out of the first pass:
- Four had their own Escape handler on `window` or `document`. Those are gone;
Escape now comes through the Modal, which works because the dialog holds
focus — the old listeners fired from anywhere on the page, including while
focus sat behind the dialog they were meant to close.
- `ApprovalDialog` and `ProposedEditDialog` use Escape to *reject*, not to
dismiss, because an agent is blocked waiting on the answer. That routes
through `onClose` and keeps its meaning. Both also set
`closeOnBackdrop={false}`: a stray click should not answer a question on the
user's behalf, and the proposal dialog holds a diff someone is reading.
- `SaveFavoriteDialog` bound Enter-to-save and Escape in one handler. Escape
went to the Modal; Enter stayed, because a favourite is one field and a
button and Enter saving it is worth keeping.
- `SQLPreviewDialog` had a bespoke overlay-click check against a ref. Both it
and the ref are gone.
- `SetVariableDialog`, `ApprovalDialog` and `ProposedEditDialog` have no
`isOpen` prop at all — they are open when their subject is non-null, and an
early return already says so.
Tests that fired Escape at `window` or `document` now fire at the dialog,
which is where a real keypress lands once the dialog has focus. Tests that
clicked the backdrop now press it, matching the mousedown behaviour introduced
with the Modal.
Doing this by hand was the right call twice over: a bulk transform broke six
files in the first attempt, and a second one silently dropped the backdrop
dimming on the two dialogs that used a separate backdrop element. Both were
caught, but neither would have been by typechecking alone.
Closes #701.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes wave 2. Closes #701 — all seventeen dialogs are now on the shared
Modal, so every dialog in the app traps focus, takes focus when it opens,closes on Escape, returns focus to whatever opened it, and announces itself as
a modal dialog.
Before this work: 0 of 17 trapped focus, 1 took focus, 4 handled Escape, 0 had
role="dialog".Why these ten were left for a second pass
They each had logic of their own.
Four had their own Escape handler on
windowordocument. Those aregone. Escape now arrives through the Modal, which works because the dialog
holds focus — the old listeners fired from anywhere on the page, including
while focus sat behind the dialog they were meant to close.
ApprovalDialogandProposedEditDialoguse Escape to reject, not todismiss, because an agent is blocked waiting on the answer. That routes through
onCloseand keeps its meaning. Both also setcloseOnBackdrop={false}— astray click shouldn't answer a question on the user's behalf, and the proposal
dialog holds a diff someone is in the middle of reading.
SaveFavoriteDialogbound Enter-to-save and Escape in one handler. Escapewent to the Modal; Enter stayed, because a favourite is one field and a button
and Enter saving it is worth keeping.
SQLPreviewDialoghad a bespoke overlay-click check against a ref. Both itand the ref are gone.
Three have no
isOpenprop at all —SetVariableDialog,ApprovalDialog,ProposedEditDialogare open when their subject is non-null, and an earlyreturn already says so.
Test changes, and why they're not weakening
window/documentnow fire at the dialog. Thatis where a real keypress lands once the dialog has focus — which it didn't
before, which was the bug.
behaviour introduced with the Modal.
On doing this by hand
Worth recording: I tried a bulk transform twice. The first broke six files. The
second silently dropped the backdrop dimming on the two dialogs that used a
separate backdrop element — a purely visual regression that typechecking and
most of the test suite would have waved straight through. Both were caught, but
only by looking.
Verification
*Dialog.tsxremains off the Modal🤖 Generated with Claude Code