Skip to content

add role navigation and semantic list to left panel nav #1047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { useTranslation } from 'react-i18next';
import { css } from 'styled-components';

import { Box, BoxButton, Icon, Text } from '@/components';
import { BoxButton, Icon, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { DocDefaultFilter } from '@/features/docs';
import { useLeftPanelStore } from '@/features/left-panel';
Expand Down Expand Up @@ -47,48 +47,50 @@ export const LeftPanelTargetFilters = () => {
};

return (
<Box
$justify="center"
$padding={{ horizontal: 'sm' }}
$gap={spacingsTokens['2xs']}
className="--docs--left-panel-target-filters"
>
{defaultQueries.map((query) => {
const isActive = target === query.targetQuery;
<nav role="navigation" aria-label="Docs filters">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Thanks for the semantic update !
You can remove role="navigation", as it’s implicit on the nav element. It’s only necessary if you're using a non-semantic container like a div.

and Also, consider updating the aria-label something like "Document sections" would be more meaningful for screen reader users than "Docs filters".

Suggested change
<nav role="navigation" aria-label="Docs filters">
<nav aria-label="Document sections">

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visual layout seems slightly broken after this change probably some missing spacing or margin on the filter items.

sidebar

<ul
className="--docs--left-panel-target-filters"
style={{ listStyle: 'none', padding: 0, margin: 0 }}
>
{defaultQueries.map((query) => {
const isActive = target === query.targetQuery;

return (
<BoxButton
aria-label={query.label}
key={query.label}
onClick={() => onSelectQuery(query.targetQuery)}
$direction="row"
aria-selected={isActive}
$align="center"
$justify="flex-start"
$gap={spacingsTokens['xs']}
$radius={spacingsTokens['3xs']}
$padding={{ all: '2xs' }}
$css={css`
cursor: pointer;
background-color: ${isActive
? colorsTokens['greyscale-100']
: undefined};
font-weight: ${isActive ? 700 : undefined};
&:hover {
background-color: ${colorsTokens['greyscale-100']};
}
`}
>
<Icon
$variation={isActive ? '1000' : '700'}
iconName={query.icon}
/>
<Text $variation={isActive ? '1000' : '700'} $size="sm">
{query.label}
</Text>
</BoxButton>
);
})}
</Box>
return (
<li key={query.label}>
<BoxButton
aria-label={query.label}
onClick={() => onSelectQuery(query.targetQuery)}
$direction="row"
aria-selected={isActive}
$align="center"
$justify="flex-start"
$gap={spacingsTokens['xs']}
$radius={spacingsTokens['3xs']}
$padding={{ all: '2xs' }}
$css={css`
width: 100%;
cursor: pointer;
background-color: ${isActive
? colorsTokens['greyscale-100']
: undefined};
font-weight: ${isActive ? 700 : undefined};
&:hover {
background-color: ${colorsTokens['greyscale-100']};
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s no visible focus outline, so it's hard to know where we are.

👉 You may need to explicitly add a :focus-visible style on the BoxButton to restore proper keyboard visibility.

Suggested change
}
}
&:focus-visible {
outline: 2px solid ${colorsTokens['primary-500']};
outline-offset: 2px;
border-radius: ${spacingsTokens['3xs']};
}
focus

`}
>
<Icon
$variation={isActive ? '1000' : '700'}
iconName={query.icon}
/>
<Text $variation={isActive ? '1000' : '700'} $size="sm">
{query.label}
</Text>
</BoxButton>
</li>
);
})}
</ul>
</nav>
);
};