You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Return focus after closing dialogs that have no DialogTrigger #1326
Radix Dialog sends focus back only to a DialogTrigger. In @radix-ui/react-dialog 1.1.17, onCloseAutoFocus blocks the default focus return and calls triggerRef.current?.focus() instead. Most ThinkRail dialogs open from a store flag or a plain onClick. So after Escape, Cancel or Confirm, focus lands on <body>, and keyboard and screen-reader users start again from the top of the page.
apps/web/src/panels/ConfirmDialog.tsx:45-52 returns focus only when onClosedAutoFocus is passed. Only ProjectTree.tsx:724 passes it. The other 11 confirms don't, for example ChatDeleteDialog.tsx:50, RemoveWorkspaceDialog.tsx:20, McpSettings.tsx:1078, ExtensionsSettings.tsx:314, useShipRunner.tsx:591,620 and LayoutSettings.tsx:524.
29 of the 36 files that render DialogContent/DialogPanel use neither DialogTrigger nor onCloseAutoFocus. That includes dialogs the user opens directly:
Settings (SettingsDialog.tsx:63, opened from the gear at shell/Shell.tsx:272)
the attachment viewer (chat/turns.tsx:233)
Skills, Find in files, New workspace, Merge PR, Compose PR and the Template editor.
Related: if a file changes while a review comment composer is open, the composer unmounts with focus in its textarea (resource-renderers/.../reviewComposerState.ts:56). StaleComposerNotice can't take focus, so focus drops to <body> while the user is typing.
Direction
Fix it once in packages/ui/dialog.tsx (DialogContent at :64, DialogPanel at :96). Remember the element that had focus when the dialog opened. On close, if the caller didn't call preventDefault() and that element is still in the page, focus it. Keep onClosedAutoFocus and onCloseAutoFocus as overrides. For the composer, move focus to the review surface or the notice. Add an e2e test: open Settings from the keyboard, press Escape, and expect focus back on the gear.
Found while documenting the component library in #1075.
Activity