Repository navigation
Commit 4fce2f6
authored
fix: name the collapsed side nav's links for screen readers (#3845)
## Summary
Fixes #3844.
With the side nav collapsed to icons, its links had no accessible name: `AppNavLink` dropped the label (`{!isCollapsed && <span>{label}</span>}`) and the collapsed logo link held only the `aria-hidden` logomark. Screen readers announced each one as "link". Lighthouse flags 7 of them on play-clickstack.
- `AppNavLink` keeps its label when collapsed, inside Mantine's `VisuallyHidden`, so the link is named with no visual change. This works for any `ReactNode` label, not only strings.
- The collapsed logo link gets the brand name from `useBrandDisplayName()` the same way.
- New `AppNavLink.test.tsx` finds the link by role and name in both states; the collapsed case fails on `main` ("Unable to find an accessible element with the role "link" and name "Search"").
- Changeset: `@hyperdx/app` patch.
### Screenshots or video
No visual change: with the nav collapsed (`isNavCollapsed` = true, 1280x720, light theme), screenshots of the rail on `main` and on this branch are pixel-identical. What changes is the accessibility tree:
| Before (`main`) | After (this branch) |
| :----- | :---- |
| Collapsed rail links: 7 with no name | `ClickStack`, `Search`, `Saved searches`, `Chart explorer`, `Client sessions`, `Service map`, `Dashboards` |
| Lighthouse "Links do not have a discernible name": 7 failing | passes |
### How to reproduce
**Starting point:** `yarn app:dev:local` + Connect to Demo Server, or https://play-clickstack.clickhouse.com/search for the "before".
**On `main`:**
1. Collapse the side nav with the "Collapse/expand navigation" button.
2. In DevTools > Accessibility, inspect the Search link: it has no name. Lighthouse lists the logo link and 6 page links under "Links do not have a discernible name".
**On this branch:**
1. Collapse the side nav the same way.
2. The Search link is named "Search" (and so on for each link; the logo link is named "ClickStack"). The Lighthouse audit passes. The rail looks the same as on `main`.
### How to test on Vercel preview
**Preview routes:** /search
**Steps:**
1. Click the button with aria-label "Collapse/expand navigation" to collapse the side nav.
2. Verify the link with data-testid "nav-link-search" has the accessible name "Search".
3. Verify the link with data-testid "nav-link-chart" has the accessible name "Chart explorer".
### References
- Linear Issue: N/A
- Related PRs: N/A
---
> [!NOTE]
> **Low Risk**
> UI-only accessibility fix with no behavior, routing, or data changes; scoped to nav presentation and covered by new unit tests.
>
> **Overview**
> When the side nav collapses to icons, **`AppNavLink`** no longer drops its label—it keeps the label in Mantine **`VisuallyHidden`** so each link still has an accessible name with no visible change.
>
> The collapsed logo link is handled by a new **`AppNavCollapsedLogo`** component that adds the brand display name via **`useBrandDisplayName()`** in **`VisuallyHidden`**, since the logomark alone is not announced.
>
> **`AppNav.tsx`** uses **`AppNavCollapsedLogo`** instead of inlining the logomark. New tests assert links are discoverable by role and name in both expanded and collapsed states.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9d9e27b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>1 parent dd3e6de commit 4fce2f6
4 files changed
Lines changed: 80 additions & 4 deletions
File tree
- .changeset
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
| |||
414 | 429 | | |
415 | 430 | | |
416 | 431 | | |
417 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
418 | 439 | | |
419 | 440 | | |
420 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments