Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/collapsed-help-button-name.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 7 additions & 1 deletion packages/app/src/components/AppNav/AppNav.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,13 @@ export const AppNavHelpMenu = ({
<span className={styles.navItemIcon}>
<HelpSparkle hasUnseen={hasUnseenWhatsNew} />
</span>
{!isCollapsed && <span>Help</span>}
{/* As in AppNavLink: keep the label for screen readers when
the collapsed rail shows only the icon. */}
{isCollapsed ? (
<VisuallyHidden>Help</VisuallyHidden>
) : (
<span>Help</span>
)}
</span>
</UnstyledButton>
</Menu.Target>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
<QueryClientProvider client={new QueryClient()}>
<MantineProvider>
<AppNavContext value={{ isCollapsed, pathname: '/search' }}>
<AppNavHelpMenu whatsNewVersion={whatsNewVersion} />
</AppNavContext>
</MantineProvider>
</QueryClientProvider>,
);

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();
});
});
Loading