Skip to content

fix(site/src/pages): scroll the whole sidebar tab into view on focus - #31394

Merged
tracyjohnsonux merged 21 commits into
mainfrom
tracy/deq-344-sidebar-tab-scroll-on-focus
Nov 25, 2026
Merged

tracyjohnsonux merged 21 commits into
mainfrom
tracy/deq-344-sidebar-tab-scroll-on-focus

Conversation

@tracyjohnsonux

@tracyjohnsonux tracyjohnsonux commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

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

In the right panel tab strip, tabbing to a closeable tab's × scrolls only the × into view, so the tab half and its focus ring stay clipped at the scroller edge. On keyboard focus (:focus-visible), each tab pill now scrolls itself into view, and scroll-px-9 keeps it clear of the 32px scroll chevron overlays. Pointer focus does not scroll: scrolling on mousedown moved the pill under the pointer and dropped the click.

Verification

Playwright tab-through of the SidebarTabView CloseableTabs story at a 420px viewport, measuring each focused pill against the visible scroller area (minus chevron overlays):

  • main: 3 of 15 forward stops clipped (Terminal 5 by 69px, Terminal 7 and its × by 45px).
  • This branch: 0 clipped, forward and backward.

Chromium, mouse press near the right visible edge of a partly hidden tab: before the keyboard-only check, the strip scrolled 46px on mousedown and the click landed on the pill wrapper; now it does not scroll and the tab receives the click.

The new CloseableTabLabelFocusedWithKeyboard story focuses a tab whose close button starts clipped. The Vitest test covers pointer focus only, because jsdom's :focus-visible inside a focus handler depends on earlier focus changes in the file.

pnpm lint, make pre-commit, and the SidebarTabView unit and story tests pass.


Generated by Coder Agents on behalf of @tracyjohnsonux.

tracyjohnsonux and others added 16 commits October 13, 2026 15:01
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.
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.
Tabbing to a closeable tab's close button scrolled only the button into
view, leaving its focus ring clipped at the scroller edge.
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

DEQ-344

…s-agents-page

# Conflicts:
#	site/src/pages/AgentsPage/components/ChatElements/tools/ToolResultImage.tsx
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 <[email protected]>
Base automatically changed from tracy/focus-indicators-agents-page to main October 29, 2026 19:25
…-tab-scroll-on-focus

# Conflicts:
#	site/src/pages/AISettingsPage/LifecyclePage/components/LifecycleSettingLayout.tsx
#	site/src/pages/AgentsPage/components/AdvisorSettings.tsx
#	site/src/pages/AgentsPage/components/AgentChatInput.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/chats/UserSidebarFooter.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/tabs/SidebarTabView.stories.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/tabs/SidebarTabView.tsx
#	site/src/pages/AgentsPage/components/ContextUsageIndicator.tsx
#	site/src/pages/AgentsPage/components/GitPanel/GitPanel.tsx
#	site/src/pages/AgentsPage/components/RightPanel/DebugPanel/DebugRunCard.tsx
#	site/src/pages/AgentsPage/components/RightPanel/DebugPanel/DebugStepCard.tsx
#	site/src/pages/AgentsPage/components/RightPanel/RightPanelAddTabControl.stories.tsx
#	site/src/pages/AgentsPage/components/RightPanel/RightPanelAddTabControl.tsx
#	site/src/pages/AgentsPage/components/WorkspacePill.tsx
@tracyjohnsonux
tracyjohnsonux marked this pull request as ready for review November 24, 2026 06:04
@tracyjohnsonux
tracyjohnsonux requested a review from a team as a code owner November 24, 2026 06:04
chrifro pushed a commit that referenced this pull request Nov 24, 2026
… the agents sidebar (#32670)

The agents sidebar had two interactions that needed a drag, with no
single-pointer alternative (WCAG 2.5.7 Dragging Movements). This PR adds
one for each and leaves the drags as they are:

- **Resizing the sidebar.** Right-clicking (or long-pressing) the resize
handle opens a "Sidebar width" menu with Decrease width, Increase width
(64px steps), and Reset width. A step is disabled when the width is
already at that limit. Widths use the same clamp-and-persist path as
dragging and the keyboard arrows.
- **Reordering pinned chats.** A pinned chat's actions menu (the "…"
button and the right-click menu) now has Move up and Move down. The
first pin has no Move up and the last pin has no Move down. Both items
call the existing `reorderPinnedChat` mutation through the handler the
drop path now shares, so the optimistic order and the error toast behave
the same as for a drag. The items are hidden while filters disable
reordering, as dragging already is.

Closes DEQ-147

| Ticket | UI surface | Screenshots |
|---|---|---|
| DEQ-147 (element 1) | `ResizableChatsSidebarFrame`: resize separator
of the agents sidebar |
[before/after](https://linear.app/codercom/issue/DEQ-147/functionality-requires-a-dragging-movement-with-no-alternative#comment-d5c646e8)
|
| DEQ-147 (element 2) | `ChatActionsMenuItems` / `SortableChatTreeNode`:
Pinned section of the agents sidebar |
[before/after](https://linear.app/codercom/issue/DEQ-147/functionality-requires-a-dragging-movement-with-no-alternative#comment-d5c646e8)
|

**Open UX question (the ticket is labeled `ux-input-needed`).** The
resize menu works and meets 2.5.7, but nothing on screen tells users it
exists: it only opens with a right-click or long-press on a 4px handle.
If design would rather have a visible control, for example width presets
in a sidebar menu, that can replace this menu.

Tests: Vitest covers Move up and Move down sending the right
`pin_order`, and each resize menu item persisting the new width. New
`ReorderPinMenu` and `ResizableSidebarContextMenu` stories capture the
open menus, including Decrease width disabled at the minimum width.

**Dropped review findings**
- DF2 (nit): add a mutation `scope` to `reorderPinnedChat` so
overlapping reorders run in order. Dropped because the menu closes after
each move, and fast keyboard drags already send absolute orders through
the same unscoped mutation. It is a separate change to shared query
code.

<details>
<summary>Grouping and decision log</summary>

- **Prior work:** checked before starting. DEQ-147 had no PRs, comments,
or attachments, and had stayed in Open since it was created. Tracy's
open sidebar PRs (#31064 moves the Pinned section, #31394 fixes focus
scroll) do not touch either drag. Moving chats into projects already has
a menu alternative (#30895), so it is out of scope.
- **Grouping:** one PR. Both elements are the same rule on the same
sidebar, and the change is about 125 non-test lines, well under the
300-line gate. Shipping them together lets the ticket close in one PR.
- **Pin reorder alternative:** menu items rather than visible up/down
buttons. The row already has an actions menu, so this adds no UI to
every row, and it follows the "Move to project" alternative used for the
project drag.
- **Resize alternative:** options were (a) a plain click on the handle
that steps or toggles the width, (b) a context menu on the handle, (c)
handing the ticket to design, and (d) a width setting. (a) has no
direction and conflicts with drag detection, and (d) is a new preference
surface, which is a product decision. (b) uses the shared `ContextMenu`
primitive and adds no permanent UI, so I chose it and raised
discoverability above as the open UX question.
- **Step size:** 64px, so the menu covers the 240px to 660px range in a
few clicks. The 16px keyboard step would take about 26.
- **Accessibility audit (axe 4.11 in Storybook, open-menu states):** no
violations introduced. These are already present on `main` and appear on
both base and branch: `color-contrast` on the faded relative timestamp
in chat rows, and `aria-hidden-focus` on `#storybook-root` whenever any
Radix context menu is open, including the existing chat-row context
menu.
- **Touch and pen (round 2):** pointerdown calls `preventDefault` only
for mouse. Calling it for touch and pen cancelled Radix's long-press
timer, and the handle is already `touch-none`. Opening the menu ends any
drag in progress, so a press that is held and then moved does not keep
resizing under the menu.
- **Review nits (round 2):** moved the menu step to `sidebarWidth.ts`
(`LEFT_SIDEBAR_MENU_RESIZE_STEP`), restored the prop docs on
`ChatTreeNode`, and switched the story wait to `screen.findByRole`. I
kept different conventions at the limits on purpose. The width menu
always has the same three items, so a disabled step tells the user it
has reached a limit. The pin menu hides Move up and Move down, the same
way it already hides Pin or Unpin when they don't apply.

</details>

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.
Scrolling on pointer focus moved the pill under the pointer during
mousedown, so clicks on partly hidden tabs landed on the pill wrapper
and did nothing.
Moves the keyboard-focus scroll onto each tab pill, so it no longer walks
the DOM to find the pill. Adds a story for a keyboard-focused tab whose
close button starts under the scroll chevron, and a test that pointer
focus does not scroll.
@tracyjohnsonux
tracyjohnsonux merged commit b9d3240 into main Nov 25, 2026
30 checks passed
@tracyjohnsonux
tracyjohnsonux deleted the tracy/deq-344-sidebar-tab-scroll-on-focus branch November 25, 2026 07:18
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 25, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — d9859a34 Deployed Nov 25, 2026 by tracyjohnsonux via cleanup #484
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants