Skip to content

fix(web): keep keyboard focus inside the tour, subtitle appearance panel, and Now Listening - #4296

Merged
Quick104 merged 3 commits into
mainfrom
fix/modal-focus-containment
Nov 15, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/modal-focus-containment

Conversation

@Quick104

@Quick104 Quick104 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • The first-run tour, which every new profile sees.
  • The subtitle appearance panel, opened from the player (including fullscreen), from Settings › Your Devices, and from Admin › Devices.
  • The audiobook Now Listening view (beta).

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

  • Tour: uses the radix Dialog primitive the rest of the app already uses, in place of a hand-rolled role="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.
  • Subtitle appearance panel: also uses radix Dialog. It still portals into document.fullscreenElement when there is one, so it stays visible over a fullscreen player. Radix returns focus only to a Dialog.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.
  • Now Listening: while it is open, its sibling elements under the app root get inert and 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

  • Keyboard in a browser against a sandbox built from this branch, on every surface: the tour on a fresh account, the panel from Your Devices, Admin › Devices and a fullscreen player, and Now Listening with an audiobook. Each was checked for where focus lands on open, whether Tab and Shift+Tab ever leave, Escape, and where focus returns. All behave as described above. The same steps on main reproduce the problem on every surface.
  • Device & override auditing — Web #1222 C1 and Device & override auditing — Web admin #1221 C1: set a subtitle appearance override on a device through the panel, reloaded, then reset it from Admin › Devices. Both still pass.
  • pnpm run lint, format:check, build (includes the typecheck), budget:check: pass.
  • Vitest for onboarding, settings, audiobooks and the subtitle menu: pass.
  • make test-web locally 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.
  • Not checked with a real screen reader. aria-hidden and inert were 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, main before 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 inert while 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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code, running inside T3 Code
  • Tool(s): Claude Code; Playwright for the browser checks
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; the agent verified it in a browser, and a human has not yet reviewed it
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Trap keyboard focus in the onboarding tour, subtitle appearance panel, and Now Listening

  • Replaces the manual portal in TourHost.tsx with a Radix Dialog. Escape skips the tour, scrim clicks no longer close it, and the primary action gets focus on open and after step changes. The app behind the tour is hidden from assistive tech.
  • Replaces the custom portal and document-level Escape listener in SubtitleAppearancePanelView.tsx with a controlled Radix Dialog that portals into the fullscreen element when present. Focus restores to the element active when the dialog opened, and the shared close handler blurs the active element first. SubtitleMenu.tsx now focuses its trigger before opening the panel.
  • NowListening.tsx marks non-inert siblings as inert on mount and focuses the collapse button, clearing inert on unmount. After Now Listening has opened once, the mini player's expand tile autofocuses via a new autoFocus prop on CoverExpandTile.tsx.
  • Risk: Now Listening's sibling inert handling could leave elements inert if unmount is skipped; verify the cleanup path in the unmount effect in NowListening.tsx.

Macroscope summarized 5e67e97.

Quick104 and others added 3 commits November 14, 2026 23:31
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]>
@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64202b5e-726c-4698-aec7-1d0496e85c00
Commits

Reviewing files that changed from the base of the PR and between fd0d8c6 and 5e67e97.

Files selected for processing: 8

  • web/src/components/onboarding/OnboardingGate.test.tsx
  • web/src/components/onboarding/TourHost.tsx
  • web/src/components/settings/SubtitleAppearancePanelView.tsx
  • web/src/pages/audiobooks/player/AudiobookPlayer.tsx
  • web/src/pages/audiobooks/player/CoverExpandTile.tsx
  • web/src/pages/audiobooks/player/MiniBar.tsx
  • web/src/pages/audiobooks/player/NowListening.tsx
  • web/src/player/components/SubtitleMenu.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T05:15:48.379270Z 5e67e97 PR opened
🔒 Security Review ✅ Completed 2026-11-15T05:17:23.158175Z 5e67e97 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.

@silo-triage silo-triage Bot added bug Something isn't working impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Nov 15, 2026
Comment on lines +47 to +50
const root = rootRef.current;
const covered = Array.from(root?.parentElement?.children ?? []).filter(
(el): el is HTMLElement => el !== root && el instanceof HTMLElement && !el.inert,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

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.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@Quick104
Quick104 merged commit 385d907 into main Nov 15, 2026
25 checks passed
@Quick104
Quick104 deleted the fix/modal-focus-containment branch November 15, 2026 06:53
Quick104 added a commit that referenced this pull request Nov 19, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant