Repository navigation
fix(web): keep keyboard focus inside the tour, subtitle appearance panel, and Now Listening - #4296
Conversation
Radix Dialog returns focus only to a Dialog.Trigger, and the subtitle appearance panel opens from plain buttons, so closing it left focus on <body>. Remember the element focused on open and return focus there. The tour disables its buttons while a step saves, which drops focus to <body>; put it back on the primary button once the next step shows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 29 minutes. View limit details
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| const root = rootRef.current; | ||
| const covered = Array.from(root?.parentElement?.children ?? []).filter( | ||
| (el): el is HTMLElement => el !== root && el instanceof HTMLElement && !el.inert, | ||
| ); |
There was a problem hiding this comment.
Now Listening leaves body-level portals outside its focus containment
Focusable body-level portals remain accessible behind the full-screen view and can receive Tab focus. Use a modal focus scope or include external portal roots in the containment strategy.
Prompt for LLM
File web/src/pages/audiobooks/player/NowListening.tsx, lines 47-50:
Now Listening leaves body-level portals outside its focus containment
The inert sweep only covers current siblings inside `#root`, so focusable body-level portals remain accessible behind Now Listening and can receive Tab focus while the full-screen view is open. Use a modal focus scope or include external portal roots in the containment strategy.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Checked this in a browser on this branch. While Now Listening is open, <body> holds nothing but #root and the entry script. The view's speed and settings menus render inside the view rather than in a portal, so Tab has no body-level target to reach. The app's toaster also renders inside #root, so it is inert along with the rest of the app.
A body-level portal shows up only when something opens on top of the view, such as a radix dialog. That dialog runs its own focus scope and marks everything else aria-hidden, Now Listening included. Inerting body-level siblings here would make such a dialog unusable, so I'm leaving the containment scoped to the app root's children. The Risks section notes the one gap: an element added under #root while the view is open would not be marked inert.
There was a problem hiding this comment.
Thanks for checking the actual portal behavior. Given that browser validation, I agree the original suggestion is not an actionable bug in the current implementation. Inerting all body-level siblings could also interfere with dialogs opened on top of Now Listening.
The documented limitation remains: a focusable element added outside the inert siblings while the view is open could escape containment. No change is needed for the body-level portal concern based on the behavior you observed.
Main rewrote StarRating for half stars (#4398); Left and Right now step half a star there and pass through at either end. TourHost takes main's version, which already restores focus to the primary button after a save (#4296). The test files main pruned in #4465 stay deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Related issue: N/A
Validation tasks: none changed; walked #1222 C1 and #1221 C1 on this branch and both still pass
Other clients: Apple N/A (web-only browser focus handling); Android N/A (web-only browser focus handling); Roku N/A (web-only browser focus handling)
Three full-screen surfaces in the web app say they are modal but leave keyboard focus in the page behind them. Keyboard and screen reader users open them and stay behind the scrim: Tab walks the hidden sidebar and page, and closing drops focus on the page body.
With this change, opening each surface moves focus into it. Tab and Shift+Tab stay inside while it is open, and the page behind it is hidden from assistive tech. Escape closes the tour and the panel, and Now Listening already collapsed on Escape. Closing returns focus to the control that opened the surface.
Approach
Dialogprimitive the rest of the app already uses, in place of a hand-rolledrole="dialog"portal. Focus starts on the primary button, and after each step it moves back there, because the buttons are disabled while the step saves. Escape skips the tour, the same as Skip. A press on the scrim still does nothing.Dialog. It still portals intodocument.fullscreenElementwhen there is one, so it stays visible over a fullscreen player. Radix returns focus only to aDialog.Trigger, and the panel opens from plain buttons, so the panel remembers what had focus when it opened and returns focus there. In the player, the menu item that opens the panel unmounts with the menu, so focus moves to the Subtitles button first. The backdrop closes the panel only when a press starts on it, so a text selection dragged out of the panel no longer closes it. Escape still blurs first, so a typed opacity is saved.inertand focus moves to its collapse button. When it collapses, the mini bar's expand button takes focus. The rest of the audiobook player is unchanged.The look of all three is unchanged apart from the visible focus ring. No new user-visible text was added.
Validation
mainreproduce the problem on every surface.pnpm run lint,format:check,build(includes the typecheck),budget:check: pass.make test-weblocally ran under heavy load from an image build and had timeouts in files this change does not touch. The failing set changed between runs, and the files compared directly passed on rerun. CI is the clean run.aria-hiddenandinertwere checked in the DOM.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4296/
Surface and build: web app and web admin, desktop and phone width,
mainbefore and this branch after, against the same sandbox.Risks
Low. These are web-only focus changes to three surfaces. Now Listening marks the app root's other children
inertwhile it is open and clears the attribute when it collapses. An element added under the app root while the view is open would not be marked inert.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Trap keyboard focus in the onboarding tour, subtitle appearance panel, and Now Listening
autoFocusprop on CoverExpandTile.tsx.inerthandling could leave elements inert if unmount is skipped; verify the cleanup path in the unmount effect in NowListening.tsx.Macroscope summarized 5e67e97.