diff --git a/.changeset/collapsed-help-button-name.md b/.changeset/collapsed-help-button-name.md new file mode 100644 index 000000000..7f9df0db6 --- /dev/null +++ b/.changeset/collapsed-help-button-name.md @@ -0,0 +1,8 @@ +--- +'@hyperdx/app': patch +--- + +fix: give the collapsed side nav's Help button an accessible name. With the nav +collapsed to icons, screen readers announced it only as "button" (or as "New +updates available" when a release was unseen). The Help label now stays 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 ad20ba7a7..5893780f0 100644 --- a/packages/app/src/components/AppNav/AppNav.components.tsx +++ b/packages/app/src/components/AppNav/AppNav.components.tsx @@ -307,7 +307,13 @@ export const AppNavHelpMenu = ({ - {!isCollapsed && Help} + {/* As in AppNavLink: keep the label for screen readers when + the collapsed rail shows only the icon. */} + {isCollapsed ? ( + Help + ) : ( + Help + )} diff --git a/packages/app/src/components/AppNav/__tests__/AppNavHelpMenu.test.tsx b/packages/app/src/components/AppNav/__tests__/AppNavHelpMenu.test.tsx new file mode 100644 index 000000000..6588902a4 --- /dev/null +++ b/packages/app/src/components/AppNav/__tests__/AppNavHelpMenu.test.tsx @@ -0,0 +1,50 @@ +import { MantineProvider } from '@mantine/core'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { render, screen } from '@testing-library/react'; + +import { + AppNavContext, + AppNavHelpMenu, +} from '@/components/AppNav/AppNav.components'; + +// The closed What's new drawer still mounts and reads the router's basePath. +jest.mock('next/router', () => ({ + useRouter: () => ({ basePath: '' }), +})); + +const renderHelpMenu = (isCollapsed: boolean, whatsNewVersion?: string) => + render( + + + + + + + , + ); + +describe('AppNavHelpMenu', () => { + beforeEach(() => { + window.localStorage.clear(); + }); + + it('names the Help button when the nav is expanded', () => { + renderHelpMenu(false); + expect(screen.getByRole('button', { name: 'Help' })).toBeInTheDocument(); + }); + + it('keeps the Help button name when the nav is collapsed to icons', () => { + renderHelpMenu(true); + expect(screen.getByRole('button', { name: 'Help' })).toBeInTheDocument(); + }); + + it('keeps the Help name next to the sparkle label when collapsed', async () => { + // A browser that has never seen the release notes gets the sparkle, which + // adds its own label to the button's name. + renderHelpMenu(true, '2.37.0'); + expect(await screen.findByTestId('whats-new-sparkle')).toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'New updates available Help' }), + ).toBeInTheDocument(); + }); +});