Skip to content

Commit

Permalink
Switch to aria-current="page" for the TOC items (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse authored Sep 27, 2024
1 parent 0ca32af commit b075f0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-hounds-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gitbook': patch
---

Fix accessibility of the table of contents by using `aria-current` instead of `aria-selected`
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export function TOCPageIcon({ page }: { page: RevisionPage }) {
'text-base',
'text-dark/6',
'dark:text-light/6',
'group-aria-selected/toclink:text-primary',
'group-aria-selected/toclink:dark:text-primary-400',
'group-aria-current-page/toclink:text-primary',
'group-aria-current-page/toclink:dark:text-primary-400',
)}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function ToggleableLinkItem(props: {
<Link
ref={linkRef}
href={href}
aria-selected={isActive}
{...(isActive ? { 'aria-current': 'page' } : {})}
className={tcls(
'group/toclink',
'flex',
Expand Down
3 changes: 3 additions & 0 deletions packages/gitbook/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const config: Config = {
],
theme: {
extend: {
aria: {
'current-page': 'current="page"',
},
fontFamily: {
sans: ['var(--font-content)'],
mono: ['var(--font-mono)'],
Expand Down

0 comments on commit b075f0f

Please sign in to comment.