Skip to content

fix(site/src/pages): show the composer focus ring only for keyboard focus - #31392

Draft
tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/deq-344-composer-keyboard-focus-ring
Draft

tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/deq-344-composer-keyboard-focus-ring

Conversation

@tracyjohnsonux

Copy link
Copy Markdown
Collaborator

Part of DEQ-344, split out of #30689 because it uses JS rather than classes alone.

The composer's focus ring targets textarea:focus, but the editor is now a contenteditable, so the composer has no focus indicator (WCAG 2.4.7). A CSS-only has-[[contenteditable]:focus] ring would also show on autofocus and click, because browsers treat every contenteditable focus as focus-visible. This PR uses document keydown/pointerdown listeners to track whether the last input was Tab, and shows a full-opacity ring-content-link only then.

  • AgentChatInput.tsx: Tab tracking and the ring.
  • AgentChatPageView.tsx and AgentCreateFormFrame.tsx: -mt-0.5 pt-0.5 so the scroll wrappers don't clip the top of the ring.
  • Stories: ComposerFocusedWithKeyboard in AgentChatInput.stories.tsx and AgentChatPage.stories.tsx.

Generated by Coder Agents on behalf of @tracyjohnsonux.

…ocus

The composer ring targeted a textarea that no longer exists, so the
contenteditable editor had no focus indicator. Browsers treat every
contenteditable focus as focus-visible, including autofocus, so the ring
shows only when focus reaches the editor via Tab. The chat page and
create form wrappers get top padding so the ring is not clipped.
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

DEQ-344

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants