From c127998128162314b8f01e76ead3b31bf791782f Mon Sep 17 00:00:00 2001 From: Kaustubh Ghodke <29895376+kaustubhdgr8@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:50:53 -0500 Subject: [PATCH 1/2] fix: name the collapsed side nav's links for screen readers With the nav collapsed to icons, AppNavLink dropped its label and the logo link held only the aria-hidden logomark, so the links had no accessible name. Keep the labels and the brand name in a VisuallyHidden element instead. --- .changeset/collapsed-nav-accessible-names.md | 8 +++++ .../components/AppNav/AppNav.components.tsx | 9 +++++- packages/app/src/components/AppNav/AppNav.tsx | 19 ++++++++++-- .../AppNav/__tests__/AppNavLink.test.tsx | 29 +++++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .changeset/collapsed-nav-accessible-names.md create mode 100644 packages/app/src/components/AppNav/__tests__/AppNavLink.test.tsx diff --git a/.changeset/collapsed-nav-accessible-names.md b/.changeset/collapsed-nav-accessible-names.md new file mode 100644 index 000000000..85da5bb89 --- /dev/null +++ b/.changeset/collapsed-nav-accessible-names.md @@ -0,0 +1,8 @@ +--- +'@hyperdx/app': patch +--- + +fix: give the collapsed side nav's links an accessible name. With the nav +collapsed to icons, the page links and the logo link had no text, so screen +readers announced them only as "link". The labels now stay in the page, +visually hidden. diff --git a/packages/app/src/components/AppNav/AppNav.components.tsx b/packages/app/src/components/AppNav/AppNav.components.tsx index 462a8128d..35d4d9641 100644 --- a/packages/app/src/components/AppNav/AppNav.components.tsx +++ b/packages/app/src/components/AppNav/AppNav.components.tsx @@ -16,6 +16,7 @@ import { Text, Tooltip, UnstyledButton, + VisuallyHidden, } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; import { @@ -414,7 +415,13 @@ export const AppNavLink = ({ > {icon} - {!isCollapsed && {label}} + {/* The collapsed rail shows only the icon. Keep the label for screen + readers, or the link has no accessible name. */} + {isCollapsed ? ( + {label} + ) : ( + {label} + )} {!isCollapsed && isBeta && ( { let redirectUrl; @@ -388,7 +397,11 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) { > {isCollapsed ? ( -
{logomark}
+
+ {logomark} + {/* The mark is aria-hidden, so name the link for screen readers. */} + {brandDisplayName} +
) : ( + render( + + + } /> + + , + ); + +describe('AppNavLink', () => { + it('names the link with its label when the nav is expanded', () => { + renderLink(false); + expect(screen.getByRole('link', { name: 'Search' })).toBeInTheDocument(); + }); + + it('keeps the accessible name when the nav is collapsed to icons', () => { + renderLink(true); + expect(screen.getByRole('link', { name: 'Search' })).toBeInTheDocument(); + }); +}); From 9d9e27b44cd4a0228d9e6578b901e4014af6c9d3 Mon Sep 17 00:00:00 2001 From: Kaustubh Ghodke <29895376+kaustubhdgr8@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:03:43 -0500 Subject: [PATCH 2/2] test: cover the collapsed logo link's accessible name Move the collapsed logo into AppNavCollapsedLogo so its brand name can be tested without mounting the whole nav. --- .../components/AppNav/AppNav.components.tsx | 14 +++++++++++++ packages/app/src/components/AppNav/AppNav.tsx | 21 ++++--------------- .../AppNav/__tests__/AppNavLink.test.tsx | 18 ++++++++++++++++ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/packages/app/src/components/AppNav/AppNav.components.tsx b/packages/app/src/components/AppNav/AppNav.components.tsx index 35d4d9641..ad20ba7a7 100644 --- a/packages/app/src/components/AppNav/AppNav.components.tsx +++ b/packages/app/src/components/AppNav/AppNav.components.tsx @@ -34,6 +34,7 @@ import { IconUserCog, } from '@tabler/icons-react'; +import { useBrandDisplayName, useLogomark } from '@/brand'; import { IS_LOCAL_MODE } from '@/config'; import { useConnections } from '@/connection'; import { setHdxClickHouseVersions } from '@/hdxDebug'; @@ -56,6 +57,19 @@ export const AppNavContext = React.createContext<{ pathname: '/', }); +// The collapsed nav's logo. The mark is aria-hidden, so the brand name is kept +// for screen readers, or the logo link has no accessible name. +export const AppNavCollapsedLogo = () => { + const logomark = useLogomark({ size: 22 }); + const brandDisplayName = useBrandDisplayName(); + return ( +
+ {logomark} + {brandDisplayName} +
+ ); +}; + export const AppNavCloudBanner = () => { return (
diff --git a/packages/app/src/components/AppNav/AppNav.tsx b/packages/app/src/components/AppNav/AppNav.tsx index 3870dfa97..5fa81cb45 100644 --- a/packages/app/src/components/AppNav/AppNav.tsx +++ b/packages/app/src/components/AppNav/AppNav.tsx @@ -6,15 +6,7 @@ import cx from 'classnames'; import { Badge } from '@clickhouse/click-ui'; import { setAttributes, setUser } from '@clickhouse/clickstack-browser'; import { SavedSearchListApiResponse } from '@hyperdx/common-utils/dist/types'; -import { - Anchor, - Collapse, - Flex, - Group, - ScrollArea, - Text, - VisuallyHidden, -} from '@mantine/core'; +import { Anchor, Collapse, Flex, Group, ScrollArea, Text } from '@mantine/core'; import { useDisclosure, useFocusTrap, useLocalStorage } from '@mantine/hooks'; import { IconBell, @@ -28,7 +20,7 @@ import { } from '@tabler/icons-react'; import api from '@/api'; -import { useBrandDisplayName, useLogomark, useWordmark } from '@/brand'; +import { useWordmark } from '@/brand'; import { AlertStatusIcon } from '@/components/AlertStatusIcon'; import { InstanceLabel } from '@/components/AppNav/InstanceLabel'; import { useMobileNavOverlay } from '@/components/AppNav/useMobileNavOverlay'; @@ -49,6 +41,7 @@ import { import { AppNavCloudBanner, + AppNavCollapsedLogo, AppNavContext, AppNavHelpMenu, AppNavLink, @@ -117,8 +110,6 @@ const NAV_LINKS: NavLinkConfig[] = [ export default function AppNav({ fixed = false }: { fixed?: boolean }) { const wordmark = useWordmark(); - const logomark = useLogomark({ size: 22 }); - const brandDisplayName = useBrandDisplayName(); useEffect(() => { let redirectUrl; @@ -397,11 +388,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) { > {isCollapsed ? ( -
- {logomark} - {/* The mark is aria-hidden, so name the link for screen readers. */} - {brandDisplayName} -
+ ) : ( { expect(screen.getByRole('link', { name: 'Search' })).toBeInTheDocument(); }); }); + +describe('AppNavCollapsedLogo', () => { + it('names the logo link with the brand name', () => { + render( + + + + + , + ); + expect( + screen.getByRole('link', { name: BRAND_DISPLAY_NAME }), + ).toBeInTheDocument(); + }); +});