Skip to content

fix(site/src): move the Autocomplete clear button out of the trigger - #31856

Merged
bartekgatzcoder merged 7 commits into
mainfrom
a11y/nested-interactive
Nov 10, 2026
Merged

bartekgatzcoder merged 7 commits into
mainfrom
a11y/nested-interactive

Conversation

@jeremyruppel

@jeremyruppel jeremyruppel commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

The Autocomplete clear control was a <span role="button" tabIndex={0}> nested inside the trigger <button>, which axe reports as nested-interactive.

It is now a real <button type="button" aria-label="Clear selection"> rendered as a sibling of the trigger inside a relative wrapper, and absolutely positioned over a 24px spacer kept in the trigger so the layout is unchanged. The className prop moves to the wrapper; every non-inline caller only passes width classes. The inline search mode is untouched.

Closes DEQ-511

Ticket Surface
DEQ-511 Workspace sharing dialog user/group picker (shared Autocomplete, also used by template permissions, chat/project sharing, and AI settings ACL dialogs)
Decision log
  • stopPropagation() removed from the clear handler: it only existed to stop the click reaching the trigger. Callers' ancestors were checked; none has a click or pointer handler, and the button is type="button" so enclosing forms don't submit.
  • The clear button's right-[33px] is the trigger's 1px border, 12px px-3, and 20px chevron box.
  • ProjectAccessDialog no longer passes clearable={false}, which only existed to avoid the nested button, and the now-unused clearable pass-through on UserOrGroupAutocomplete is removed.
  • No focus restoration after clearing (no extra ref). Focus drops to the body when the clear button unmounts, which matches current main behavior.
  • Clicking clear while the dropdown is open now also closes it, since the button is outside the popover trigger.
  • The nested-interactive batch also covers the templates list, audit log, and template builder base-template cards; those ship as separate PRs. The "Select modules" tickets were already fixed by fix(site/src/pages/TemplateBuilder): use shared Checkbox in ModuleCard #30540.

🤖 Generated by Coder Agents on behalf of @jeremyruppel.

…he trigger

The clear control was a span with role="button" nested inside the trigger
button, which axe reports as nested-interactive. It is now a real button
rendered beside the trigger and positioned over the same spot.
@linear-code

linear-code Bot commented Nov 6, 2026

Copy link
Copy Markdown

DEQ-511

…s original position

right-8 left the button 1px right of where it sat inside the trigger,
because it ignored the trigger's 1px border.
jeremyruppel added a commit that referenced this pull request Nov 6, 2026
…ing rows buttons (#31857)

Template rows used `useClickableTableRow`, which rendered `<tr
role="button" tabIndex={0}>` around the "Create Workspace" link, so axe
reports `nested-interactive` on every row.

Rows are now plain table rows with the existing hover outline and a
mouse-only click that opens the template. The template name is a real
link to the template page (shared `Link` with `asChild`, same pattern as
`WorkspaceTopbar`), so keyboard and screen reader users reach the
template through it. The name link stops propagation like the Create
Workspace button already does, so Ctrl/Cmd-click opens a new tab without
also navigating the current one.

Closes DEQ-46
Closes DEQ-94
Closes DEQ-237
Closes DEQ-293
Closes DEQ-311

| Ticket | Surface |
|---|---|
| DEQ-46, DEQ-94, DEQ-237, DEQ-293, DEQ-311 | Templates list
(`/templates`) rows |

The resting state is pixel-identical to `main`. The only visible change
is keyboard focus: it moves from the whole row to the template name,
which gets the standard `content-link` focus ring.

<details>
<summary>Decision log</summary>

- Chose a real name link over the `WorkspacesTable` precedent of
dropping `role` but keeping `tabIndex={0}` on the row. A focusable row
without a role doesn't tell assistive technology it navigates, and
`site/AGENTS.md` requires a semantic role for `tabIndex={0}`.
- `Link` overrides (`pl-0 font-semibold text-inherit
visited:text-inherit`) keep the title's existing look; computed color,
weight, and size match `main` in both themes.
- Verified with axe-core in Storybook (`pages/TemplatesPage`
WithTemplates, MultipleOrganizations, ClassicParameterFlowWarning):
`nested-interactive` goes from 6/6/3 nodes to 0. A pre-existing minor
`empty-table-header` remains on both.
- New `TemplatesPage.test.tsx` opens a template from the name link with
the keyboard; it fails on `main`.
- The rest of the `nested-interactive` batch ships separately (#31856
for `Autocomplete`).

</details>

🤖 Generated by Coder Agents on behalf of @jeremyruppel.

@bartekgatzcoder bartekgatzcoder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1: changes needed. The fix works: the clear control is now a real <button> beside the trigger, so nested-interactive is resolved, every caller's className move checks out, and label wiring is unchanged. Three should-fix items before this can merge:

  1. [should-fix] New focus state has no story (Autocomplete.tsx:412, TS1/FE1). The clear button gains a visible focus-visible ring the old span never had, but no story captures it for Pixel. Add a story (for example ClearButtonFocused) whose play only tabs to or focuses "Clear selection", with no assertions.
  2. [should-fix] Long single-line class list (Autocomplete.tsx:412, site/AGENTS.md class-list rule). Split it into cn(...) groups: position, box/reset, hover, focus.
  3. [should-fix] Stale workaround comment (site/src/pages/AgentsPage/components/ProjectPage/ProjectAccessDialog.tsx:283-284, outside the diff). // Its clear control would nest a button inside the trigger button. next to clearable={false} is false once this PR lands. Either drop the comment and clearable={false} (the clear control is now safe there), or reword the comment to the real reason for keeping it disabled.

Nits:

  • Autocomplete.tsx:375: the rewrite dropped cn(...) and left a bare multiline template literal, which site/AGENTS.md asks to avoid. placeholder:text-content-secondary there has no effect on a <button>.
  • Autocomplete.tsx:412: p-0 border-0 bg-transparent cursor-pointer duplicate preflight and index.css base rules. right-[33px] is border (1px) + px-3 (12px) + chevron size-5 (20px). Worth a line in the PR body.
  • Autocomplete.stories.tsx:349-369: the edited ClearSelection play still asserts onChangeSpy and text content. The new Vitest test covers onChange(null), so the play can stop at the click.
  • Focus drops to body after clearing. This matches main, but returning focus to the trigger would be a small improvement while this control is being rewritten.

Follow-ups filed (pre-existing, not blocking): DEQ-621 (trigger aria-haspopup="listbox" but popup is a dialog); evidence added to DEQ-176 (sharing picker has no label).

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@bartekgatzcoder
bartekgatzcoder marked this pull request as draft November 10, 2026 16:02
bartekgatzcoder pushed a commit that referenced this pull request Nov 10, 2026
…closure button (#31858)

The audit log row header was a `<div role="button" tabIndex={0}
aria-expanded>` that contained the description links and the request
details tooltip trigger, so axe reports `nested-interactive` on every
expandable row.

The chevron is now a real disclosure button (`CollapsibleTrigger` around
a `<button aria-label="View changes">`), which gets `aria-expanded` and
`aria-controls` from Radix and handles Enter and Space natively. The
header div keeps its click handler as a mouse-only shortcut, with no
role, tab stop, or key handler. The button stops propagation so a click
toggles once.

Closes DEQ-28
Closes DEQ-106
Closes DEQ-211
Closes DEQ-250
Closes DEQ-317
Closes DEQ-392
Closes DEQ-438

| Ticket | Surface |
|---|---|
| DEQ-28, DEQ-106, DEQ-211, DEQ-250, DEQ-317, DEQ-392, DEQ-438 | Audit
log (`/audit`) expandable rows |

<details>
<summary>Decision log</summary>

- Kept the row-wide click for mouse users, matching current behavior,
with an `oxlint-disable-next-line jsx-a11y/click-events-have-key-events`
comment, as `ModuleCard` does (#30540). Keyboard users use the
disclosure button. Dropping the row click would avoid the comment but
shrink the mouse target to the 24px chevron.
- The button's name is a static "View changes"; the expanded state comes
from `aria-expanded`.
- Replaced the two `fireEvent.keyDown` tests in `AuditPage.test.tsx`,
which exercised the removed row key handler, with one `userEvent` test
that toggles the button with Enter, Space, and a click and checks it
toggles once each time.
- Verified with axe-core in Storybook (`pages/AuditPage/AuditLogRow`
WithDiff, WithOrganization, NoDiff): `nested-interactive` goes from 1
node to 0 in the diff stories. A `target-size` hit on the request
details tooltip trigger in WithOrganization also clears, since it no
longer sits inside the oversized row button.
- Related `nested-interactive` fixes: #31856 (`Autocomplete`), #31857
(templates list).

</details>

🤖 Generated by Coder Agents on behalf of @jeremyruppel.
bartekgatzcoder pushed a commit that referenced this pull request Nov 10, 2026
…template cards (#31865)

The base template card in the template builder was a `<div role="radio"
tabIndex={0}>` with its own Enter and Space handling, and it contained
the "View details" link, so axe reports `nested-interactive` on every
card.

The card now uses the shared `RadioGroupItem` in place of the hand-drawn
indicator, labelled by the template name, and `BaseInfraSelectStep`
wraps the grid in the shared `RadioGroup` controlled by
`selectedBaseId`. The group gets one Tab stop with arrow-key navigation.
The card keeps its click handler as a mouse-only shortcut with no role,
tab stop, or key handler, matching `ModuleCard` (#30540).

Closes DEQ-50
Closes DEQ-60
Closes DEQ-61
Closes DEQ-166
Closes DEQ-197
Closes DEQ-205
Closes DEQ-242
Closes DEQ-445
Closes DEQ-452

| Ticket | Surface |
|---|---|
| DEQ-50, DEQ-60, DEQ-61, DEQ-166, DEQ-197, DEQ-205, DEQ-242, DEQ-445,
DEQ-452 | Template builder, step 1 (pick a base template) |

<details>
<summary>Decision log</summary>

- The radio has no change handler. Clicks, Space, and Radix's arrow-key
selection all reach the card as clicks, so the card's `onClick` is the
only caller of `onSelect` and a selection is never counted twice.
Covered by `TemplateCard.test.tsx`.
- Kept the card-wide click for mouse users with an
`oxlint-disable-next-line jsx-a11y/click-events-have-key-events`
comment, as `ModuleCard` does.
- The selected radio now uses the shared style (gray border, 10px dot)
instead of the custom one (white border, 8px dot). Size and position are
unchanged. Focus moves from a ring around the whole card to a ring
around the radio, offset against the card surface.
- Clicking "View details" still selects the card on the way out, as
before and as in `ModuleCard`.
- `TemplateCard` stories render inside a `RadioGroup` decorator, which
the radio needs.
- Verified with axe-core in Storybook: `TemplateCard` Default and
Selected go from `nested-interactive` and `target-size` (1 node each) to
0. `TemplateBuilderPageView` Default goes from 2 nodes each to 0. A
pre-existing `link-in-text-block` hit in the page subtitle remains.
- Related `nested-interactive` fixes: #31856 (`Autocomplete`), #31857
(templates list), #31858 (audit log).

</details>

🤖 Generated by Coder Agents on behalf of @jeremyruppel.
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 16:03 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
@jeremyruppel jeremyruppel reopened this Nov 10, 2026
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:06 — with GitHub Actions Inactive
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:16 — with GitHub Actions Inactive
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:16 — with GitHub Actions Inactive
@jeremyruppel

Copy link
Copy Markdown
Collaborator Author

Addressed the remaining review-summary items:

  • Stale clearable={false} workaround in ProjectAccessDialog: removed with its comment (54c554b). Its only caller gone, the clearable pass-through on UserOrGroupAutocomplete is removed too (f3aae25).
  • ClearSelection play now stops at the click; the Vitest test covers onChange(null).
  • right-[33px] breakdown added to the PR description.
  • Focus returning to the trigger after clear: not done here. triggerRef is caller-supplied, so it would need a merged ref, and behavior matches main. Happy to do it in a follow-up.
  • Merged main and resolved conflicts in Autocomplete.tsx and Autocomplete.test.tsx (kept both tests).

Generated by Coder Agents on behalf of @jeremyruppel.

@jeremyruppel jeremyruppel changed the title fix(site/src/components/Autocomplete): move the clear button out of the trigger fix(site/src): move the Autocomplete clear button out of the trigger Nov 10, 2026
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:16 — with GitHub Actions Inactive
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:21 — with GitHub Actions Inactive
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:40 — with GitHub Actions Inactive
@jeremyruppel
jeremyruppel marked this pull request as ready for review November 10, 2026 16:51
@jeremyruppel
jeremyruppel requested a review from a team as a code owner November 10, 2026 16:51
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 16:51 — with GitHub Actions Inactive
@coder coder unlocked this conversation Nov 10, 2026

@bartekgatzcoder bartekgatzcoder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2: all three should-fix items are resolved. The ClearButtonFocused story only tabs to the clear button, the class lists use cn(...) groups, and the stale clearable={false} workaround is gone from ProjectAccessDialog along with its unused pass-through. Verified at e5efea9: axe shows no violations on the Autocomplete stories or the ProjectAccessDialog Manage stories, the focus ring is visible on "Clear selection", and Enter or a click clears the value; tsc, biome, oxlint, and the affected Vitest suites (88 tests) pass. Follow-up filed: DEQ-625 (focus drops to body after clearing, which matches main and was deferred by the author).

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@bartekgatzcoder
bartekgatzcoder merged commit bb76cfc into main Nov 10, 2026
33 checks passed
@bartekgatzcoder
bartekgatzcoder deleted the a11y/nested-interactive branch November 10, 2026 21:09
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 21:09 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026

This branch was previously deployed

1 inactive deployment
main — e5efea9f Deployed Nov 10, 2026 by bartekgatzcoder via cla #253723
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.

2 participants