Repository navigation
fix(site/src/pages): return focus when the chat search dialog closes - #31393
Merged
Merged
Conversation
The dialog opens without a Radix Dialog.Trigger, so Radix returned focus to the document body on close.
tracyjohnsonux
marked this pull request as ready for review
October 28, 2026 06:24
tracyjohnsonux
added a commit
that referenced
this pull request
Oct 29, 2026
Fixes DEQ-344 Fixes the axe Auditor finding "Focus indicator is missing" on `/agents` (WCAG 2.4.7, Deque issue 2880281, DEQ-344). All rings use the same `ring-content-link` token as `Button` and #30354. This PR is class changes only. The fixes that need JS are split out: - #31392: composer focus ring, shown only for keyboard focus. - #31393: return focus when the chat search dialog closes. - #31394 (stacked on this PR): scroll the whole sidebar tab into view on focus. - **AI spend trigger** (`UsageIndicator`): this is the flagged element. It set `outline-hidden` and had nothing to replace it. It now shows a 2px inset ring on `:focus-visible`. The ring is inset because the button fills the full height of the sidebar footer. - **Account menu button** (`UserSidebarFooter`): gets the same inset ring so the two adjacent footer buttons match. Before, it relied on the browser default outline. - **Number fields** (`AdvisorSettings`, `LifecycleSettingLayout`): the inputs hide their outline and the label wrapper had no focus style. The wrapper now gets a `focus-within` ring, the same pattern `ChatSearchInput` uses. - **Sidebar chat row kebab** (`ChatTreeNode`): stayed at `opacity-0` when focused with the keyboard. It now shows, and the timestamp hides, while anything in the row has `:focus-visible`. This matches hover and `ProjectChatRow`. - **Subagent expand/collapse toggle** (`ChatTreeNode`): it used `invisible` (`visibility: hidden`), which removed it from the tab order, so keyboard users could not expand subagents. It now uses `opacity-0` and shows on `:focus-visible`, in place of the status icon. `pointer-events-none` outside hover keeps touch behavior unchanged. - **Clipped rings in `overflow-hidden` groups:** the right panel `+` / Add panel split button (`RightPanelAddTabControl`), the Git diff Unified/Split toggle (`GitPanel`), and the Debug panel run and step headers (`DebugRunCard`, `DebugStepCard`) had their outer ring or browser outline clipped by the rounded container. Only a sliver at the divider showed. They now use an inset ring. The tool result image button (`ToolResultImage`) uses an outline with a -2px offset instead, because the image would cover an inset box-shadow. - **Right panel tabs** (`SidebarTabView`): the tab strip scrolls horizontally, which also clips vertically, so tab rings lost their top and bottom edges. A closeable tab's close button also painted over the tab's ring. The strip now has 2px padding offset by a negative margin, so rings fit. In closeable tabs, the tab and its close button each draw their own inset ring, like the `+` / Add panel split button, so it's clear which half has focus. - **Chat search results** (`ChatSearchResults`): focus stays in the search input, and the arrow-selected row is set via `aria-activedescendant`. That row showed only a `surface-tertiary/40` tint (about 1.1:1 against the dialog). It now draws the inset `content-link` ring. Hover doesn't set the selection, so mouse hover keeps the plain tint. - **Consistent treatment in the composer** (`AgentChatInput`, `WorkspacePill`, `ContextUsageIndicator`): every pill now gets the model selector's full-strength 2px `content-link` ring around the whole pill. Pill dismiss `×` buttons ring their parent pill (`has-focus-visible`) and highlight the `×`, instead of drawing Chrome's two-tone default outline on the icon. The workspace pill, `+N` overflow, and MCP group triggers gained the ring. The context usage ring lost its 40% opacity. The badge row is `overflow-hidden` for overflow measurement, so pill rings there are inset, and the composer's model selector is inset to match. - **Stories:** `UsageIndicator` `TriggerFocusedWithKeyboard`, `ChatsSidebar` `ChatActionsTriggerFocusedWithKeyboard`, and `RightPanelAddTabControl` `AddPanelFocusedWithKeyboard`, and `SidebarTabView` `CloseableTabFocusedWithKeyboard` focus the trigger so Pixel captures it. `ChatsSidebar` `ExpandCollapse` now toggles with the keyboard, because `userEvent.click` does not apply CSS `:hover`. The existing `LifecyclePageView` stories already focus the number inputs. Menu items inside the AI spend dropdown are covered by #30354. <details> <summary>Implementation plan and decision log</summary> **Scope.** Deque flagged one element. A scan of `site/src` found every `outline-hidden`/`outline-none` that has no `focus-visible` or `focus-within` replacement. Shared menu and combobox primitives are already handled in #30354, and the remaining `components/` hits are either non-interactive containers (Dialog, Popover, Drawer, Chart) or already have a ring. The Agents-area hits fixed here are the trigger and the two number fields. The composer is in #31392. A scan for `role="button"` or `tabIndex=0` elements without focus styles in `pages/AgentsPage` found none. **Decisions.** - Inset ring for the footer buttons. An outer ring would be clipped at the footer and sidebar edges. - Full-opacity rings. `/40` rings reach only about 2.1:1 (dark) and 1.8:1 (light), below the 1.4.11 minimum of 3:1. Full opacity is 7.9:1 and 5.2:1. - Changes that need JS (composer Tab tracking, search focus return, tab scroll on focus) are split into #31392, #31393, and #31394 so this PR is easy to review. **Verification.** In Storybook, the computed `box-shadow` shows `rgb(97,166,250) 0 0 0 2px` on the focused trigger and lifecycle field, and no ring when they're blurred. A Playwright tab-through of `ChatsSidebar` confirms the kebab and subagent toggle become visible with a ring on keyboard focus, Enter toggles subagents, and mouse hover and click behave as before. Pixel sampling of focused screenshots shows the ring on all four edges of the Add panel, New terminal, Unified, and Split buttons, the Debug card header, and the tool result image. A Playwright tab-through of the composer shows the same `rgb(97,166,250) 0 0 0 2px` ring on More options, the model selector, MCP and planning pills (via their dismiss button), the workspace pill, and context usage. Pixel sampling of the right panel tab strip, tabbing forward and backward through `CloseableTabs`, `MultipleTabs`, and `GitWithBadge`, finds the ring on all four edges of each focused tab that starts in view. `pnpm check`, `pnpm lint`, `pnpm lint:types`, the `UsageIndicator`, `AgentChatInput`, `ChatsSidebar`, `RightPanelAddTabControl`, `GitPanel`, `DebugPanel`, and `Tool` story tests, and the `ChatsSidebar` and `AgentsPageLayout` Vitest files pass. **Not done.** No manual keyboard pass in Firefox or Safari yet. `ux-input-needed`: design hasn't confirmed the inset ring style. </details> --- *Generated by Coder Agents on behalf of @tracyjohnsonux.* --------- Co-authored-by: Jake Howell <jacob@coder.com>
jaaydenh
approved these changes
Nov 6, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Part of DEQ-344, split out of #30689 because it uses JS rather than classes alone.
The chat search dialog opens without a Radix
Dialog.Trigger, so on close Radix sends focus tobody. The dialog now records the focused element and pathname on open, and restores focus on close unless the element is gone or the route changed (picking a result navigates away).Covered by "ChatsSidebar search dialog › returns focus to the search button when dismissed", which fails without the fix.
Open question from #30689 (thread): whether to move this onto
useDialogFocusReturn(). That hook remembers only a clicked button, so it would need to acceptdocument.activeElementto cover the keyboard shortcut. I'll follow up here once that's settled.Generated by Coder Agents on behalf of @tracyjohnsonux.