Repository navigation
fix(site/src): add visible focus indicators on the Agents page - #30689
Conversation
The AI spend trigger in the Agents sidebar footer removed the browser outline without a replacement (WCAG 2.4.7, Deque DEQ-344). Add an inset content-link ring on focus-visible, and match it on the adjacent account menu button. Also fix the chat composer ring, which targeted a textarea while the editor is a contenteditable, and raise it to full opacity for 3:1 contrast. Add focus-within rings to the Advisor and Lifecycle number fields, whose inputs hide their outline.
The chat row actions trigger stayed at opacity 0 when focused with the keyboard, and the subagent expand toggle used visibility hidden, which removed it from the tab order. Show both on focus-visible, matching their hover behavior.
…ontrols Buttons inside overflow-hidden containers (the right panel add-tab split button, Git diff style toggle, Debug panel cards, and tool result images) had their outer focus ring or browser outline clipped. Draw the ring inset, or as an inward outline for the image button whose content would cover an inset ring.
Composer pills now share the model selector's full-strength 2px content-link ring around the whole pill. The dismiss X rings its parent pill instead of drawing the browser outline on the icon, the workspace pill and +N/MCP group triggers get the ring, and the context usage ring drops its 40% opacity. Rings in the clipped badge row are inset. Add a base :focus-visible outline in the same color and width so raw elements without their own focus style no longer fall back to the browser's default two-tone outline.
The editor is focused programmatically on load and after sends, and browsers treat every contenteditable focus as focus-visible, so the composer looked keyboard-focused before any input. Show the ring only when focus reaches the editor via Tab; the caret marks other focus.
The tab strip scrolls horizontally, which also clips vertically, so tab focus rings lost their top and bottom edges. A closeable tab's close button also painted over the tab's ring, and focus scrolled only the focused half of a closeable tab into view. Pad the strip for the ring, ring closeable tabs as one pill like the composer badges, and scroll the whole pill clear of the scroll chevrons on focus.
…ages The composer sits flush with the top of a vertically scrolling wrapper on the chat page (and the mobile create form frame), which clipped the ring's top edge. Pad the wrappers by the ring width, offset by a negative margin so the layout does not shift.
Ringing the whole tab and close pill when either half had focus made it unclear which control was focused. Give the tab and close button their own inset ring, matching the add-tab split button.
Search keeps DOM focus in the input and marks the arrow-selected result with aria-activedescendant. That row was shown only by a background tint with about 1.1:1 contrast. Draw the inset content-link focus ring on it.
Radix dialogs restore focus only to a Dialog.Trigger, and the chat search dialog opens from the sidebar button or Ctrl+K, so dismissing it left focus on the document body. Remember the element focused on open and return to it on close, unless the dialog closed by navigating to a result.
Browsers already draw a visible default outline on raw elements, and each real failure is fixed in its component. The global rule only recolored that outline app-wide.
There was a problem hiding this comment.
Could we turn this into just one more hook? (Sorry Kayla)
I feel like this is something were going to need again.
There was a problem hiding this comment.
useDialogFocusReturn()exists in #30856 , happy if we take that approach here 🙂
There was a problem hiding this comment.
Thanks! Before switching over, I want to check how you'd like to handle two cases where useDialogFocusReturn() doesn't quite fit the search dialog yet:
- Keyboard shortcut. Search can also open from the keyboard shortcut anywhere on the page, for example while typing in the composer. The hook only remembers a button through
rememberTrigger(event), so after a shortcut open it has nothing to return focus to, and focus ends up onbody. - Picking a result. Selecting a chat navigates to it. The sidebar search button is still mounted, so the hook would pull focus back to it on the new page. The current code skips restoring focus when the pathname has changed.
Options:
- A. Extend the hook with a way to remember
document.activeElementon open (widening the ref fromHTMLButtonElementtoHTMLElement), and keep the pathname check inChatSearchDialog. The skills dialogs keep their current behavior. - B. Use the hook as is, wired to the two search buttons. The change is smaller, but focus no longer returns after a shortcut open.
- C. Keep the local logic for now and revisit when another dialog needs the same thing.
I'm leaning toward A. Does that work for you, or would you rather keep the hook button-only?
Generated by Coder Agents on behalf of @tracyjohnsonux.
There was a problem hiding this comment.
Moved this change to #31393 so #30689 stays class-only. The hook question above carries over there.
Generated by Coder Agents on behalf of @tracyjohnsonux.
jakehwll
left a comment
There was a problem hiding this comment.
LGTM codewise otherwise 🙂
| onFocus={(event) => { | ||
| let pill: Element | null = event.target; | ||
| while (pill && pill.parentElement !== event.currentTarget) { | ||
| pill = pill.parentElement; | ||
| } | ||
| pill?.scrollIntoView({ block: "nearest", inline: "nearest" }); | ||
| }} |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
[P2] Avoid scrolling the close button away during a pointer click.
Reproduced in Chromium with the CloseableTabFocusedWithKeyboard story: scroll until a tab's label is partly clipped off the left edge but its close button is visible, then click that close button. Mouse-down focuses it, this handler scrolls the whole pill, and mouse-up lands on the label instead of the close button. The tab stays open. Disabling this handler makes the same click close the tab.
Some explicit keyboard-focus scrolling is justified with this layout: without it, native focus scrolling leaves tabs partly clipped or obscured by the overlay chevrons. Could we keep that reveal but skip ordinary pointer focus, for example by checking the focused element's :focus-visible state? In the browser comparison, that guard preserved Tab/Shift+Tab reveal and fixed the lost click.
The ancestor walk itself could also be avoided by handling focus on the pill wrapper and using event.currentTarget, but that's optional cleanup; preventing movement during pointer activation is the important fix.
Generated by Coder Agents on behalf of @jakehwll.
| const [isEditorKeyboardFocused, setIsEditorKeyboardFocused] = useState(false); | ||
| useEffect(() => { | ||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| lastInputWasTabRef.current = event.key === "Tab"; |
There was a problem hiding this comment.
[P2 / FE6] Preserve the focus ring for keyboard-induced focus that does not follow Tab.
Reproduced in Chromium using the composer Storybook story:
- Focus the editor and type a message.
- Tab to Send and press Enter.
- Focus returns to the editor, but its ring disappears.
Enter sets this flag to false before handleSubmit calls internalRef.current?.focus() (line 1200), so the focus handler suppresses the ring. The editor still matches the browser :focus-visible selector. Keyboard focus is not limited to focus immediately preceded by Tab.
Could we replace the document-level listeners and custom focus state with CSS targeting the actual editor, such as :has([contenteditable="true"]:focus-visible)? The original textarea selector does need fixing, but this extra machinery suppresses a legitimate keyboard-focus state. That CSS also shows the ring on autofocus; if suppressing initial autofocus is an explicit design requirement, please keep that exception narrowly scoped rather than suppressing other keyboard-induced focus.
Generated by Coder Agents on behalf of @jakehwll.
Keep this PR to class-only focus indicators. The composer keyboard-only ring, the chat search focus return, and the tab scroll-into-view on focus each move to their own PR.
…s-agents-page # Conflicts: # site/src/pages/AgentsPage/components/ChatElements/tools/ToolResultImage.tsx
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-linktoken asButtonand #30354. This PR is class changes only. The fixes that need JS are split out:fix(site/src/pages): show the composer focus ring only for keyboard focus #31392: composer focus ring, shown only for keyboard focus.
fix(site/src/pages): return focus when the chat search dialog closes #31393: return focus when the chat search dialog closes.
fix(site/src/pages): scroll the whole sidebar tab into view on focus #31394 (stacked on this PR): scroll the whole sidebar tab into view on focus.
AI spend trigger (
UsageIndicator): this is the flagged element. It setoutline-hiddenand 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 afocus-withinring, the same patternChatSearchInputuses.Sidebar chat row kebab (
ChatTreeNode): stayed atopacity-0when focused with the keyboard. It now shows, and the timestamp hides, while anything in the row has:focus-visible. This matches hover andProjectChatRow.Subagent expand/collapse toggle (
ChatTreeNode): it usedinvisible(visibility: hidden), which removed it from the tab order, so keyboard users could not expand subagents. It now usesopacity-0and shows on:focus-visible, in place of the status icon.pointer-events-noneoutside hover keeps touch behavior unchanged.Clipped rings in
overflow-hiddengroups: 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 viaaria-activedescendant. That row showed only asurface-tertiary/40tint (about 1.1:1 against the dialog). It now draws the insetcontent-linkring. 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 2pxcontent-linkring 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,+Noverflow, and MCP group triggers gained the ring. The context usage ring lost its 40% opacity. The badge row isoverflow-hiddenfor overflow measurement, so pill rings there are inset, and the composer's model selector is inset to match.Stories:
UsageIndicatorTriggerFocusedWithKeyboard,ChatsSidebarChatActionsTriggerFocusedWithKeyboard, andRightPanelAddTabControlAddPanelFocusedWithKeyboard, andSidebarTabViewCloseableTabFocusedWithKeyboardfocus the trigger so Pixel captures it.ChatsSidebarExpandCollapsenow toggles with the keyboard, becauseuserEvent.clickdoes not apply CSS:hover. The existingLifecyclePageViewstories already focus the number inputs.Menu items inside the AI spend dropdown are covered by #30354.
Implementation plan and decision log
Scope. Deque flagged one element. A scan of
site/srcfound everyoutline-hidden/outline-nonethat has nofocus-visibleorfocus-withinreplacement. Shared menu and combobox primitives are already handled in #30354, and the remainingcomponents/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 forrole="button"ortabIndex=0elements without focus styles inpages/AgentsPagefound none.Decisions.
/40rings 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.Verification. In Storybook, the computed
box-shadowshowsrgb(97,166,250) 0 0 0 2pxon the focused trigger and lifecycle field, and no ring when they're blurred. A Playwright tab-through ofChatsSidebarconfirms 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 samergb(97,166,250) 0 0 0 2pxring 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 throughCloseableTabs,MultipleTabs, andGitWithBadge, finds the ring on all four edges of each focused tab that starts in view.pnpm check,pnpm lint,pnpm lint:types, theUsageIndicator,AgentChatInput,ChatsSidebar,RightPanelAddTabControl,GitPanel,DebugPanel, andToolstory tests, and theChatsSidebarandAgentsPageLayoutVitest files pass.Not done. No manual keyboard pass in Firefox or Safari yet.
ux-input-needed: design hasn't confirmed the inset ring style.Generated by Coder Agents on behalf of @tracyjohnsonux.