Skip to content

fix(site/src): stop dropdown menus hiding the page from assistive technology - #31969

Merged
jeremyruppel merged 3 commits into
mainfrom
a11y/aria-hidden-focus
Nov 10, 2026
Merged

jeremyruppel merged 3 commits into
mainfrom
a11y/aria-hidden-focus

Conversation

@bartekgatzcoder

@bartekgatzcoder bartekgatzcoder commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Opening a dropdown menu, such as the workspace row actions menu on /workspaces, set aria-hidden="true" on the page root while its links and buttons stayed focusable. axe reports this as aria-hidden-focus (WCAG 4.1.2). The cause is Radix's modal default: it hides every sibling of the menu portal.

The shared DropdownMenu is now non-modal by default. A menu button is not a modal dialog under WAI-ARIA, and Radix menus still keep Tab inside the menu and return focus on Escape. Callers can still pass modal. Three follow-ups keep the behavior modal menus had:

  • Outside click: the click that dismisses a menu no longer reaches the element under the pointer, for mouse and touch. Before this, dismissing a row's actions menu by clicking the row opened the workspace. The listener is released on the next interaction, so later clicks go through. It is skipped when the press lands outside an open dialog or popover, because Radix closes those on that same click.
  • Dialogs opened from an item: focus moving into a dialog an item opens no longer counts as an outside interaction, so focus returns to the trigger when the dialog closes. Other focus moves, such as into an iframe, still dismiss the menu.
  • Long-press Send menu: the Agents Send menu cancels the mousedown that ends a long press, so focus stays in the menu. The stale pointerEventsCheck workarounds in its test and in UserDropdownContent.test.tsx are removed.

One remaining side effect: the page no longer scroll-locks while a menu is open.

Closes DEQ-92

Ticket UI surface
DEQ-92 Every DropdownMenu (reported on the /workspaces row actions menu). No visual change, so no screenshots.

Declined review finding: a Vitest case for focus returning to the trigger after a dialog opened from an item closes. In jsdom the case fails on main too, because without close animations the menu unmounts before the dialog records the focused element. It can't model the browser sequence. The browser-run SecretsPageView DeleteAndCancel story covers it, and DEQ-623 tracks the pre-existing fragility.

Declined nit: I did not reuse DIALOG_SELECTOR from useClipboard.ts. It is private to that hook and also matches native dialog[open], and a shared UI primitive should not import from the clipboard hook.

Grouping and decision log
  • One ticket in the aria-hidden-focus batch. The audit screenshot shows the row actions menu open, and the flagged element div.flex.flex-col.min-h-screen.justify-between is the DashboardLayout root that Radix's hideOthers hides.
  • I fixed it in the shared primitive because every modal DropdownMenu has the same violation.
  • I considered keeping menus modal and making the hidden siblings inert. Radix offers no option for that, so it would need a custom hide-others layer.
  • Round 2 (reviewer):
    • The click swallow is added in onPointerDownOutside. In Radix 1.1.19, menus don't set deferPointerDownOutside, so that handler runs on pointerdown for touch too.
    • Releasing the listener on a timer would let touch clicks through, so it is released on the next click, pointerdown, pointercancel, contextmenu or keydown.
    • Radix Dialog and Popover defer their dismissal to the click and stay open if its propagation is stopped. So the swallow is skipped when the press lands outside one of them. The AgentChatInput LongWorkspaceNameMobile story caught this: a menu inside a popover must close both on one outside click.
  • Verification:
    • axe 4.11 on the DropdownMenu story: base reports aria-hidden-focus (serious) on #storybook-root, the branch reports none.
    • Playwright on WorkspacesPageView UnfilteredSingleResult, with touch (hasTouch, tap) and with mouse. On the branch, the dismissing press triggers 0 row clicks and the next press triggers 1. On the round 1 commit it was 1, then 2.
    • Keyboard: Enter opens the menu and focuses the first item, Tab stays inside, and Escape closes it and returns focus to the trigger.
    • Full unit and Storybook suites pass. New DropdownMenu.test.tsx cases fail without the fix.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

…hnology

Radix dropdown menus are modal by default and set aria-hidden on the rest of the page while it stays focusable, which axe reports as aria-hidden-focus. Make the shared DropdownMenu non-modal by default, keep focus returning to the trigger after an item opens a dialog, and keep the long-press Send menu open when the press ends.
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 15:26 — with GitHub Actions Inactive
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 15:26 — with GitHub Actions Inactive
@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

DEQ-92

@bartekgatzcoder
bartekgatzcoder marked this pull request as ready for review November 10, 2026 15:38
@bartekgatzcoder
bartekgatzcoder requested a review from a team as a code owner November 10, 2026 15:38
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 15:38 — with GitHub Actions Inactive

@jeremyruppel jeremyruppel 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.

[reviewer-agent] round 1: changes needed.

The fix removes aria-hidden-focus on the reported surface: axe 4.11 on pages/WorkspacesPage UnfilteredSingleResult with the row actions menu open reports it on #storybook-root on base and not on this branch. Keyboard open, Tab containment, and Escape focus return all still work. Gates pass (scope, size, CI, ticket link, commit title).

One blocking regression and one coverage gap, inline. Nits:

  • AgentChatSendButton.tsx:245: on base the modal trap pulled focus back into the menu after the long-press release focused Send. Now focus stays on Send while the menu is open. Also, suppressClickRef stays true if no click follows the press, and that keeps blocking focus-outside dismissal.
  • DropdownMenu.test.tsx:10: neither caller passes onOpenChange, so create the vi.fn() inside renderMenu.
  • DropdownMenu.test.tsx:34: the only check is a bare getByRole; wrap it in an explicit expect.
  • DropdownMenu.tsx:48: useClipboard.ts:6 already has a matching DIALOG_SELECTOR (module-private).

Follow-ups filed (pre-existing, not caused by this PR):

  • DEQ-623: the Workspace row actions menu loses focus to body after the Stop confirm dialog closes. Same on base.
  • DEQ-624: the Workspaces search combobox has aria-valid-attr-value (aria-expanded=true, and aria-controls points at a missing id). Base masks it only while a modal menu hides the page.

🤖 Generated by Coder Agents on behalf of @jeremyruppel.

*/
export const DropdownMenu: React.FC<
React.ComponentProps<typeof DropdownMenuPrimitive.Root>
> = ({ modal = false, ...props }) => {

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.

[blocking] Making every DropdownMenu non-modal lets the click that dismisses a menu reach the page underneath. On the surface this ticket reports, that is a regression. In pages/WorkspacesPage UnfilteredSingleResult, open "Workspace actions" and click the row's Template cell. On this branch, the menu closes and the row's onClick fires (1 click captured on the tr), so the page navigates to the workspace and the table unmounts. On base, the menu only closes (0 row clicks). Any clickable row or card with a menu (around 58 importing files) has the same problem. The PR body lists this side effect, but it does not mention clickable rows.

Suggested fix: keep non-modal for the a11y fix, but swallow the click from the pointer interaction that dismissed the menu. For example, in onPointerDownOutside, add a one-shot capture-phase click listener on document that stops it. Add a Vitest case for it: menu open, click an outside element that has an onClick, assert that the handler is not called. If you prefer to keep the default modal and opt out per call site, that also works, but it leaves the violation everywhere else.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 732185a. DropdownMenuContent now stops the click that ends an outside press, so dismissing the row's actions menu only closes it.

  • Removal: the listener is released on the next click, pointerdown, pointercancel, contextmenu or keydown, not on a timer, so touch taps are covered as well.
  • Skip: it is skipped when the press lands outside an open dialog or popover. Radix defers their dismissal to that click and keeps them open if its propagation is stopped (AgentChatInput LongWorkspaceNameMobile).
  • Tests: in DropdownMenu.test.tsx, "closes without activating the element clicked outside" fails without the fix. A right-click case checks that later clicks aren't swallowed.
  • Browser check: Playwright on WorkspacesPageView UnfilteredSingleResult with touch tap and with mouse. The dismissing press triggers 0 row clicks, and the next press triggers 1. On a3f9965 it was 1, then 2.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

// An item that opens a dialog moves focus into it. Keep that from
// counting as an outside interaction, so focus returns to the
// trigger when the dialog closes.
onFocusOutside={(event) => {

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.

[should-fix] No Vitest test covers the dialog exemption. The SecretsPageView DeleteAndCancel story asserts it in a play function, and FE1 says behavior must not be covered only by a story. Add a case to DropdownMenu.test.tsx: a menu item opens a Dialog, the dialog closes, and focus is back on the trigger. It should fail without this branch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not adding this one. I wrote the case (an item opens a Dialog, Cancel closes it, then waitFor focus on the trigger), and in jsdom it fails on main too, with focus ending on body. jsdom runs no close animations, so the menu content unmounts before the dialog records the previously focused element, and the test can't model the browser sequence. It would never have passed against either version, so it guards nothing.

The browser-run SecretsPageView DeleteAndCancel story (Storybook Vitest project, Chromium) already covers this branch: it fails without the exemption and passes with it. The underlying fragility of item-to-dialog focus return is the pre-existing issue you filed as DEQ-623. I've noted this in the PR body.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@jeremyruppel
jeremyruppel marked this pull request as draft November 10, 2026 16:20
…page

Non-modal menus let the click that dismisses them reach the element underneath, so closing a row's actions menu by clicking the row opened the workspace. Stop that click unless the press lands outside an open dialog or popover, which needs it to dismiss too. Keep focus in the long-press Send menu by stopping the mousedown that ends the press.
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 17:10 — with GitHub Actions Inactive
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 17:10 — with GitHub Actions Inactive
@bartekgatzcoder
bartekgatzcoder marked this pull request as ready for review November 10, 2026 17:25
@bartekgatzcoder
bartekgatzcoder temporarily deployed to main November 10, 2026 17:25 — with GitHub Actions Inactive

@jeremyruppel jeremyruppel 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.

[reviewer-agent] round 2: approved at 732185a. The dismissing press no longer activates what is under it: in Chromium on pages/WorkspacesPage UnfilteredSingleResult, a mouse or touch dismissal gives 0 row clicks and the next press gives 1. axe no longer reports aria-hidden-focus with the menu open, and keyboard open, Tab, Escape, and reopen all work. I accept the declined jsdom dialog test, since the browser-run DeleteAndCancel story covers that branch. Nits: an AbortController would simplify swallowNextClick's teardown, and the two inline handlers could be named helpers. Also note that open menus no longer lock page scroll. Follow-ups: DEQ-623, DEQ-624.

🤖 Generated by Coder Agents on behalf of @jeremyruppel.

@jeremyruppel
jeremyruppel merged commit ad532d0 into main Nov 10, 2026
37 checks passed
@jeremyruppel
jeremyruppel deleted the a11y/aria-hidden-focus branch November 10, 2026 17:50
@jeremyruppel
jeremyruppel temporarily deployed to main November 10, 2026 17:51 — 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 — 732185a7 Deployed Nov 10, 2026 by jeremyruppel via cla #253635
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