Repository navigation
fix(site/src): stop dropdown menus hiding the page from assistive technology - #31969
Conversation
…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.
jeremyruppel
left a comment
There was a problem hiding this comment.
[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,suppressClickRefstaystrueif no click follows the press, and that keeps blocking focus-outside dismissal.DropdownMenu.test.tsx:10: neither caller passesonOpenChange, so create thevi.fn()insiderenderMenu.DropdownMenu.test.tsx:34: the only check is a baregetByRole; wrap it in an explicitexpect.DropdownMenu.tsx:48:useClipboard.ts:6already has a matchingDIALOG_SELECTOR(module-private).
Follow-ups filed (pre-existing, not caused by this PR):
- DEQ-623: the Workspace row actions menu loses focus to
bodyafter the Stop confirm dialog closes. Same on base. - DEQ-624: the Workspaces search combobox has
aria-valid-attr-value(aria-expanded=true, andaria-controlspoints 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 }) => { |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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,contextmenuorkeydown, 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 (
AgentChatInputLongWorkspaceNameMobile). - 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
WorkspacesPageViewUnfilteredSingleResultwith touchtapand 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) => { |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
…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.
jeremyruppel
left a comment
There was a problem hiding this comment.
[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.
Opening a dropdown menu, such as the workspace row actions menu on
/workspaces, setaria-hidden="true"on the page root while its links and buttons stayed focusable. axe reports this asaria-hidden-focus(WCAG 4.1.2). The cause is Radix's modal default: it hides every sibling of the menu portal.The shared
DropdownMenuis 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 passmodal. Three follow-ups keep the behavior modal menus had:pointerEventsCheckworkarounds in its test and inUserDropdownContent.test.tsxare removed.One remaining side effect: the page no longer scroll-locks while a menu is open.
Closes DEQ-92
DropdownMenu(reported on the/workspacesrow 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
maintoo, because without close animations the menu unmounts before the dialog records the focused element. It can't model the browser sequence. The browser-runSecretsPageViewDeleteAndCancelstory covers it, and DEQ-623 tracks the pre-existing fragility.Declined nit: I did not reuse
DIALOG_SELECTORfromuseClipboard.ts. It is private to that hook and also matches nativedialog[open], and a shared UI primitive should not import from the clipboard hook.Grouping and decision log
aria-hidden-focusbatch. The audit screenshot shows the row actions menu open, and the flagged elementdiv.flex.flex-col.min-h-screen.justify-betweenis theDashboardLayoutroot that Radix'shideOthershides.DropdownMenuhas the same violation.inert. Radix offers no option for that, so it would need a custom hide-others layer.onPointerDownOutside. In Radix 1.1.19, menus don't setdeferPointerDownOutside, so that handler runs onpointerdownfor touch too.pointerdown,pointercancel,contextmenuorkeydown.AgentChatInputLongWorkspaceNameMobilestory caught this: a menu inside a popover must close both on one outside click.aria-hidden-focus(serious) on#storybook-root, the branch reports none.WorkspacesPageViewUnfilteredSingleResult, 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.DropdownMenu.test.tsxcases fail without the fix.🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.