From 92a0ba89aa89f351a2a8dc73b13b5297d7f0d0d5 Mon Sep 17 00:00:00 2001 From: Mika Nevalainen Date: Tue, 24 May 2022 11:21:56 +0300 Subject: [PATCH 1/9] Add aria-label support into Navigation component --- .../src/components/navigation/Navigation.stories.tsx | 2 +- .../navigation/navigationRow/NavigationRow.test.tsx | 5 +++-- .../navigation/navigationRow/NavigationRow.tsx | 10 ++++++++-- .../__snapshots__/NavigationRow.test.tsx.snap | 1 + .../components/sideNavigation/SideNavigation.test.tsx | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/react/src/components/navigation/Navigation.stories.tsx b/packages/react/src/components/navigation/Navigation.stories.tsx index 0f24e15bfe..5499b59fe5 100644 --- a/packages/react/src/components/navigation/Navigation.stories.tsx +++ b/packages/react/src/components/navigation/Navigation.stories.tsx @@ -52,7 +52,7 @@ export const Default = ({ searchLabel, searchPlaceholder, authenticated, userNam // @ts-ignore {/* NAVIGATION ROW */} - + e.preventDefault()} /> e.preventDefault()} /> e.preventDefault()} /> diff --git a/packages/react/src/components/navigation/navigationRow/NavigationRow.test.tsx b/packages/react/src/components/navigation/navigationRow/NavigationRow.test.tsx index 6069d52a67..807b6b5c5d 100644 --- a/packages/react/src/components/navigation/navigationRow/NavigationRow.test.tsx +++ b/packages/react/src/components/navigation/navigationRow/NavigationRow.test.tsx @@ -7,11 +7,12 @@ import { NavigationWrapper } from '../../../utils/test-utils'; describe(' spec', () => { it('renders the component', () => { - const { asFragment } = render(, { wrapper: NavigationWrapper }); + const { asFragment } = render(, { wrapper: NavigationWrapper }); expect(asFragment()).toMatchSnapshot(); }); + it('should not have basic accessibility issues', async () => { - const { container } = render(, { wrapper: NavigationWrapper }); + const { container } = render(, { wrapper: NavigationWrapper }); const results = await axe(container); expect(results).toHaveNoViolations(); }); diff --git a/packages/react/src/components/navigation/navigationRow/NavigationRow.tsx b/packages/react/src/components/navigation/navigationRow/NavigationRow.tsx index c6751b2ac1..5ac33708c7 100644 --- a/packages/react/src/components/navigation/navigationRow/NavigationRow.tsx +++ b/packages/react/src/components/navigation/navigationRow/NavigationRow.tsx @@ -17,9 +17,13 @@ export type NavigationRowProps = React.PropsWithChildren<{ * `inline` - items will be displayed in the header */ variant?: NavigationVariant; + /** + * aria-label for helping screen readers to distinguish navigation row from other navigational components + */ + ariaLabel?: string; }>; -export const NavigationRow = ({ variant = 'default', children }: NavigationRowProps) => { +export const NavigationRow = ({ variant = 'default', ariaLabel, children }: NavigationRowProps) => { const { setNavigationVariant } = useContext(NavigationContext); useEffect(() => setNavigationVariant(variant), [setNavigationVariant, variant]); @@ -43,7 +47,9 @@ export const NavigationRow = ({ variant = 'default', children }: NavigationRowPr }); return ( - + ); }; NavigationRow.componentName = 'NavigationRow'; diff --git a/packages/react/src/components/navigation/navigationRow/__snapshots__/NavigationRow.test.tsx.snap b/packages/react/src/components/navigation/navigationRow/__snapshots__/NavigationRow.test.tsx.snap index d8d1d8ac82..4f2aa87ef3 100644 --- a/packages/react/src/components/navigation/navigationRow/__snapshots__/NavigationRow.test.tsx.snap +++ b/packages/react/src/components/navigation/navigationRow/__snapshots__/NavigationRow.test.tsx.snap @@ -114,6 +114,7 @@ exports[` spec renders the component 1`] = `