Repository navigation
Description
Page or section
The site header (website/src/css/custom.css, right-hand navbar cluster) on every page.
Issue description
The theme toggle was moved to the left of the search field, and it was done with order rather than by changing the markup:
@media (min-width: 997px) {
.navbar__items--right > div[class*='colorModeToggle'] {
order: -1;
}
}order only repaints boxes. The markup is still search, GitHub, toggle, so the visual and the keyboard disagree:
| order | |
|---|---|
| what you see | toggle, search, GitHub |
| what Tab visits | search, GitHub, toggle |
| what a screen reader reads | search, GitHub, toggle |
Measured positions in the right cluster: toggle 867, search 915, GitHub 1171.
This breaks WCAG 2.4.3 (Focus Order) and 1.3.2 (Meaningful Sequence): a keyboard user watches the focus ring jump from the middle of the bar to the right, then back to the left.
Background: Docusaurus renders the toggle after the configured right-hand items, inside theme/Navbar/Content, and there is no config option to position it. order was the one-line shortcut.
Proposed change
Preferred, roughly fifteen lines and no framework internals in the repo:
colorMode: { disableSwitch: true }indocusaurus.config.ts, which removes the built-in toggle.- Swizzle
theme/NavbarItem/ComponentTypesand register a custom item type, for examplecustom-colorModeToggle, that renders@theme/ColorModeTogglewithuseColorMode()from@docusaurus/theme-common. - Place that item in
navbar.itemswhere it belongs, between the left items and the search item, and delete theorderrule.
Then the markup order and the visual order are the same thing, and the drawer picks the same item up because navbar items render there too.
Fallbacks, if the custom item type turns out to fight the mobile drawer:
- Swizzle
theme/Navbar/Contentand emit the toggle before the items. Works, but copies about a hundred lines of framework code that then has to be re-checked on every Docusaurus upgrade. - Keep
orderand accept the mismatch. Cheap, and wrong for keyboard and screen reader users.
Worth checking on the fix: the drawer still shows the toggle, colorMode.disableSwitch does not silently remove it from mobile, and the row order is unchanged at 1280 and 390.
Activity
feat(website): the bar, and the phone menu as a sheet