Skip to content

fix: make the side nav's user menu reachable from the keyboard - #3851

Open
kaustubhdgr8 wants to merge 2 commits into
ClickHouse:mainfrom
kaustubhdgr8:fix/user-menu-keyboard
Open

kaustubhdgr8 wants to merge 2 commits into
ClickHouse:mainfrom
kaustubhdgr8:fix/user-menu-keyboard

Conversation

@kaustubhdgr8

@kaustubhdgr8 kaustubhdgr8 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The user menu at the bottom of the side nav (avatar, name, team) opens User preferences, Team settings and Log out. Its Menu.Target was a Mantine Paper, which renders a <div>: it has no tabindex, so Tab skips it, and Enter and Space do nothing. Keyboard users could not open the menu at all, in either nav state. Screen readers did not expose it as a control either.

  • The trigger renders Paper as a <button type="button"> (component="button"), so it is focusable and opens with Enter and Space through Mantine's Menu.
  • .userMenu gets the rules a <button> needs to look like the old <div>: display: block, the width the block used to fill, and resets for the browser's border, font, colour and centred text. :focus-visible uses the same highlight as hover, as the nav links do.
  • Collapsed to the avatar, the button holds the user's name in VisuallyHidden, so it is named "Jane Doe" rather than only "JD". Expanded, its visible text already names it.
  • New AppNavUserMenu.test.tsx: in both nav states, Tab focuses the trigger and Enter opens the menu ("User preferences" appears). Both fail on main ("Unable to find an accessible element with the role "button" and name /Jane Doe/").
  • Changeset: @hyperdx/app patch.

Screenshots or video

No visual change. Screenshots of the full nav (1280x720, yarn app:dev:local, dev overlays hidden) on main and on this branch are pixel-identical in light and dark, expanded and collapsed, apart from the Help icon's twinkling sparkle, which is mid-animation in each shot. The trigger's box is the same (expanded 234x36 at 8,676; collapsed 30x30 at 10,676).

Before (main) After (this branch)
<div>, tabIndex -1, not in the accessibility tree as a control <button>, tabIndex 0, button named "Local mode" (local mode)
Enter / Space: nothing Enter / Space: menu opens

How to reproduce

Starting point: yarn app:dev:local + Connect to Demo Server.

On main:

  1. Click into the page, then press Tab repeatedly. Focus never lands on the user menu at the bottom of the side nav.
  2. In DevTools, the element with data-testid="user-menu-trigger" is a <div> with no tabindex.

On this branch:

  1. Tab reaches the user menu after the nav items; it shows the same highlight as on hover.
  2. Enter or Space opens the menu; arrow keys move through its items as before.
  3. Collapse the nav: the avatar button is still reachable and is named with the user's name.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Verify the element with data-testid "user-menu-trigger" is a button.
  2. Focus it with the keyboard and press Enter; verify the element with data-testid "user-preferences-menu-item" is visible.

References


Note

Low Risk
Localized a11y and styling on the nav user menu trigger with regression tests; no auth, data, or API changes.

Overview
Fixes an accessibility gap in the side nav user menu: the Mantine Menu.Target was a Paper rendering a <div>, so Tab skipped it and Enter/Space did not open User preferences or Log out.

The trigger is now Paper with component="button" and type="button", with SCSS resets (display, width, border, font, text-align) and :focus-visible styling aligned with hover so appearance stays the same. The avatar gets aria-hidden; when the nav is collapsed, VisuallyHidden supplies the full display name so the control is not only announced as initials.

Adds AppNavUserMenu.test.tsx covering Tab focus and Enter/Space opening the menu in expanded and collapsed states, plus a @hyperdx/app patch changeset.

Reviewed by Cursor Bugbot for commit 066cb7b. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Nov 27, 2026

Copy link
Copy Markdown

@kaustubhdgr8 is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 066cb7b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kaustubhdgr8
kaustubhdgr8 marked this pull request as ready for review November 30, 2026 17:24
@kaustubhdgr8
kaustubhdgr8 requested a review from a team as a code owner November 30, 2026 17:24
@github-actions github-actions Bot added external needs-vouch Author needs a maintainer to vouch for them labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @kaustubhdgr8, thanks for the pull request!

Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open — a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem.

To make that quick, check the PR description has:

  • The issue it addresses (ideally one labelled Accepting PR) and why the change is needed
  • Steps to reproduce the problem and verify the fix, starting from https://play.hyperdx.io or yarn app:dev:local connected to the demo server
  • Before/after screenshots if anything in the UI changed

More detail in our contributing guide.

@@ -133,6 +137,8 @@ export const AppNavUserMenu = ({
<Avatar size="sm" radius="xl" color="gray">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — The avatar initials stay in the button's accessible name, so screen readers hear 'JD Jane Doe', or 'U Local mode' in local mode

Add aria-hidden to the <Avatar> so the collapsed button is named just displayName, which is the intent of the new VisuallyHidden. Then make the test assert the exact name ({ name: 'Jane Doe' }) instead of /Jane Doe/, since the regex accepts the duplicated initials.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 066cb7b: the avatar is aria-hidden, and the test now asserts the exact names ('Jane Doe' collapsed, 'Jane Doe Acme' expanded).

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 1 P3

No inline comments. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/AppNav/__tests__/AppNavUserMenu.test.tsx:1 — Second AppNavUserMenu.test.tsx duplicates an existing suite and skips the shared renderWithMantine helper → Move these keyboard cases into the existing packages/app/src/components/__tests__/AppNavUserMenu.test.tsx, which already has describe('AppNavUserMenu') and the same AppNavContext setup. Render with the global renderWithMantine as that file does, not a bare <MantineProvider>. As it stands, the component's tests are split across two same-named files, and this one renders without the app's theme and ClickUIProvider.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a tightly scoped accessibility fix: the side-nav user-menu trigger moves from a <div> (via Mantine Paper) to component="button" type="button", with SCSS resets for visual parity, a VisuallyHidden name when the nav is collapsed, an aria-hidden avatar, and a new keyboard-activation test. Ref forwarding through Menu.Target and Tooltip, polymorphic typing of Paper, and the accessible-name computation all check out. No behavioral regression was found, and all prior review feedback is reflected in the current code.

🟡 P2 -- recommended

  • packages/app/src/components/AppNav/AppNav.module.scss:534 -- :focus-visible shares the hover rule and sets outline: none, so keyboard focus on the now-focusable trigger is signalled only by a background change identical to hover, which can undercut the fix's own goal of a visible keyboard affordance.
    • Fix: Confirm the background-only focus cue is a sufficiently visible focus indicator in both themes, or add a distinct :focus-visible treatment (e.g. a ring) rather than suppressing the outline.
    • maintainability, project-standards
🔵 P3 nitpicks (2)
  • packages/app/src/components/AppNav/AppNav.components.tsx:128 -- rendering the trigger as a <button> places flow content (Group's <div> and Mantine Text's <p>) inside it, which is spec-invalid for <button>; there is no runtime, hydration, or React-warning impact today, so this is a markup-validity nit only.

    • Fix: If strict markup validity matters, render the inner Text/layout nodes as <span> (phrasing content) so the button contains only phrasing descendants.
  • packages/app/src/components/AppNav/AppNav.module.scss:545 -- .userMenuCollapsed keeps border: none !important while the base .userMenu now sets border: 0; the later equal-specificity rule already wins, so the !important is dead weight and the 0/none split reads as a contradiction.

    • Fix: Drop the !important (and consider removing the collapsed border declaration entirely since the base already zeroes it).

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments.

Testing gaps:

  • Local-mode naming path is unexercised: with IS_LOCAL_MODE defaulting false in tests, the collapsed VisuallyHidden resolving to 'Local mode' (and the Menu.Label branch) is never covered.
  • The empty/undefined teamName case for the expanded accessible name is untested; only the teamName-present path is asserted.
  • Pre-existing (out of scope): AppNav.components.tsx is 476 lines, over the documented 300-line file-size guideline; not introduced or materially worsened by this diff.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@kaustubhdgr8

Copy link
Copy Markdown
Contributor Author

Thanks. In 066cb7b:

  • as const on the it.each table, as in useMetadata.test.tsx (local tsc --noEmit was already clean).
  • Space-key cases next to Enter, in both nav states.
  • The avatar initials are now aria-hidden (also covers the P3 on line 141).

Focus cue: left as is. It is the same :focus-visible rule the nav links use (outline: none plus the active background), so a stronger ring would be a separate change for the whole nav. The P3s are left as is.

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

external needs-vouch Author needs a maintainer to vouch for them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant