Skip to content

fix(a11y): trap keyboard focus in remaining top-level dialogs - #1255

Merged
currentbits merged 1 commit into
mainfrom
coder/a11y-modal-focus-leftover-916
Sep 10, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/a11y-modal-focus-leftover-916

Conversation

@currentbits

@currentbits currentbits commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Leftover from #916 / #920. This thread's worktree could not land: it was a 134-commit diverged fork. This PR is that leftover replayed onto current main.

useModalFocus on:

  • Settings
  • Onboarding
  • Keyboard sheet
  • Add project
  • Edit project
  • Web token gate

Each dialog gets a ref, tabIndex={-1}, initial focus, Tab cycling, and restore on close. Copy and save/submit logic are unchanged.

Mounted tests: opening each dialog moves document.activeElement inside it, and Tab stays inside.

Leftover from #916 / #920. Wire useModalFocus onto Settings, Onboarding,
KeyboardSheet, Add project, Edit project, and the web token gate so Tab
stays inside each overlay.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T15:19:44.993956Z 3bab92a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit f5e0c5a into main Sep 10, 2026
3 of 6 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bab92a2b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}, [onClose, pending]);

useEscapeClose(true, handleClose);
useModalFocus(true, dialogRef);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make the nested focus traps stack-aware

When a first-run user reaches the onboarding Setup step and clicks Add project, App.handleAddProject only sets addPathOpen, so OnboardingModal remains mounted while this call installs a second document-level useModalFocus trap. Both hooks redirect every focusin outside their own root; focusing an add-project input therefore bounces focus between the two dialogs recursively, while Tab remains trapped in the onboarding dialog, making this supported add-project flow keyboard-inoperable. Suspend the onboarding trap while the child dialog is open, close onboarding before opening it, or make useModalFocus manage a topmost-modal stack.

Useful? React with 👍 / 👎.

@currentbits
currentbits deleted the coder/a11y-modal-focus-leftover-916 branch October 3, 2026 16:07
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.

1 participant