Repository navigation
fix(site): add visible keyboard focus to audit log rows, menus, and comboboxes - #30354
Conversation
Expandable audit log rows had no focus indicator because the focus style lived on the table row rather than the focusable element. Menu items only changed background on focus, which matched the checked state of radio items and had too little contrast. Show an inset link-color ring on keyboard focus for both. Menu items hide the ring while hovered because Radix moves focus to the pointer's item, which Chrome treats as focus-visible.
…u story Covers keyboard focus on the checked proxy radio item so Pixel captures the focus ring.
…nder the pointer Hiding the ring on hover left no indicator when keyboard focus landed on the item under a resting cursor, which on checked radio items recreated the missing focus indicator. The ring now follows :focus-visible, so it also shows when Radix moves focus to the hovered item.
…space footer link The New workspace template options, the workspaces filter rows, and the "See all templates" link only changed background color on focus. Add the same inset content-link ring used for menu items. cmdk keeps focus in the input, so the ring keys off data-selected on the highlighted row.
aqandrew
left a comment
There was a problem hiding this comment.
Looks great! Particularly the consistency with other controls
A tiny (8px) nit I have is re: the focus ring for when AuditLogRow receives keyboard focus. Right now the TimelineEntry's vertical borders overlap the focus ring.
Are we able to make it so that the focus ring stays on top? I think their affordance is negatively impacted if they're overlapped like that. Either way, approving to unblock you
|
@aqandrew Fixed in ca019eb. The timeline line is an absolutely positioned I checked this in the Generated by Coder Agents. |
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>
Fixes the axe Auditor finding "Focus indicator is missing" (WCAG 2.4.7, issue 2863090). The finding was reported on the Audit Logs page. The fix goes into the shared menu and combobox primitives, so every dropdown, context menu, and command/combobox list in the app gets a visible keyboard focus indicator, not just the audit page.
All indicators use the same 2px inset
ring-content-linkring (#61A6FA) thatButton,Link,Select, and other controls already use for focus.AuditLogRow): the focusablediv[role=button]had no focus style.TimelineEntryputs itsfocus-visibleoutline on the<tr>, which never receives focus. The ring now shows on:focus-visible.menuClasses,DropdownMenuRadioItem): focus only changed the background from#09090bto#18181b, and on radio items that looked the same as the checked state. The ring now shows on:focus-visible. Radix moves focus to the item under the pointer, so the ring also follows the mouse. This is intentional: it keeps the indicator visible when keyboard focus lands on the item under a resting cursor.CommandItem,FilterComboboxItem): cmdk keeps DOM focus in the search input, so the ring keys offdata-selected=trueon the highlighted row. This covers the Workspaces filter (FilterComboboxItem), plus the Audit select filters, the New workspace template list, and otherCombobox/Command-based pickers (CommandItem).WorkspacesButton): adds the ring on:focus-visible.ProxyMenuOpenedWithKeyboardopens the menu with Enter, so Pixel captures the ring on a focused, checked radio item.Pixel snapshots cover the menu, combobox, and story changes across the app.
Decision log
TimelineEntrycells and menu content useoverflow-hidden, which clips an outer ring.:focus-visibleeverywhere.data-selected), not on:focus-visible, because cmdk never moves DOM focus off the input. As a result, the highlighted row shows the ring for both mouse and keyboard users.Generated by Coder Agents on behalf of @chrifro.