Repository navigation
Name docs landmarks and raise dark comment contrast - #28
Conversation
The docs chrome had no main landmark, unnamed code regions, and a Shiki comment at 3.65:1. These are the changes from the approved accessibility plan. Co-authored-by: Rodrigo <rodrigo.ccordoba@hotmail.com>
RodCor
left a comment
There was a problem hiding this comment.
changes needed. one blocker.
blocker: the landmarks are only applied on the first page load. docs-landmarks.tsx:13 runs useLayoutEffect(..., []) from docs/layout.tsx:9. app router layouts stay mounted during client-side navigation, so after you click from /docs to another docs page in the sidebar, the effect doesn't run again. the new page's code-block regions don't get labels, and the toc/main roles only stay if fumadocs happens to reuse the same nodes. the axe 0 you measured was on fresh loads, which doesn't exercise this.
passing looks like: the effect re-runs on navigation (e.g. usePathname() in the deps, or a scoped MutationObserver on #nd-page), plus evidence of axe 0 violations at 1440 and 390 after a client-side nav, for example loading /docs, clicking through to /docs/network/connect-your-tools in the sidebar, then running axe.
non-blocking:
- patching fumadocs' DOM after hydration (ids like
nd-page/nd-toc, the "Copy Anchor Link" strip at :7) breaks quietly on a fumadocs upgrade. if DocsLayout/DocsPage has a prop for the main element or the toc wrapper, prefer it. either way, add a test that fails if those ids disappear. - global.css:28: the comment-color override matches the inline style string exactly, so a casing change in the shiki theme would silently undo it. a test that pins the rule is enough.
- the color change and contrast math pass (5.72:1), the homepage code block is byte-identical, and there are no copy changes.
Page and contents roles go through fumadocs props, and each code block gets its label from CodeBlock viewportProps, so a new page renders them again. The mobile contents header has no prop, so its role is set when the path changes. The comment-color rule also matches the spaced style string the client writes. Co-authored-by: Rodrigo <rodrigo.ccordoba@hotmail.com>
RodCor
left a comment
There was a problem hiding this comment.
changes needed at 4a135d3. the first-load blocker is fixed, but two things still block. verify is green.
re-check of the last review:
- fixed: main and the toc navs now come from DocsPage props (page.tsx:26-42), so every page renders them again. the mobile contents header is re-roled with
[pathname]deps (docs-landmarks.tsx:15-21). the code labels come from CodeBlock viewportProps (docs-code.tsx:9). - fixed: tests/docs-a11y-chrome.test.mjs pins the fumadocs ids (nd-page, nd-toc, nd-docs-layout, nd-subnav, the region role) and all four comment-color selectors, and it fails if the deps go back to
[]. - still passes: comment #8b949e on #191919 is 5.72:1, the homepage code block is byte-identical, and there are no copy changes.
blockers:
- the after-navigation axe evidence is missing. that was the passing condition for the last blocker. the axe 0 in the body is for 9611375 on fresh loads. passing looks like: on 4a135d3, load /docs, click through the sidebar to /docs/network/connect-your-tools (no reload), run axe-core at 1440 and at 390, and post the violation counts. also refresh the body, which still says head 9611375 and "the diff is the three files" (it has 6 now), and say whether the after screenshots still match this head.
- docs-code.tsx:9: every code region gets a label like "Code sample «R1ab»".
useId()output isn't meant for people, so a screen reader reads that noise out for every code block. passing looks like: a name a person can understand. use the block's title or language when there is one (e.g. "bash code"), otherwise "Code sample 1", "Code sample 2" in page order. it still needs to be unique per page for landmark-unique, and the test regex at tests/docs-a11y-chrome.test.mjs needs updating to match.
| export function DocsPre({ children, ...props }: ComponentProps<"pre">) { | ||
| const id = useId(); | ||
| return ( | ||
| <CodeBlock {...props} viewportProps={{ "aria-label": `Code sample ${id}` }}> |
There was a problem hiding this comment.
blocker: useId() makes the label "Code sample «R1ab»", which a screen reader reads out as noise on every block. use the title or language ("bash code") or a page-order number ("Code sample 1"), keep it unique per page, and update the test regex.
useId labels were read aloud as generated ids. Each block now uses its title, or the language plus a page-order number, reset whenever the path changes. Co-authored-by: Rodrigo <rodrigo.ccordoba@hotmail.com>
RodCor
left a comment
There was a problem hiding this comment.
changes needed at d937659. blocker 2 is fixed; blocker 1 needs one refresh because this commit changed the build. verify is still running.
re-check of the last review:
- fixed: the code labels are readable now. code-sample-label.mjs gives the title, or "${lang} code ${order}", or "Code sample ${order}", strips « » :, and de-dupes with " 2", " 3". useId is gone and tests/docs-a11y-chrome.test.mjs pins all of that.
- fixed at 4a135d3, stale now: the body has the axe run after a soft nav (same document, marker kept, one navigation entry) with 0 violations and 0 incomplete at 1440 and 390. But that run was on 4a135d3. d937659 adds a rehype transformer in source.config.ts and a new label path, and it changes the region labels that landmark-unique checks.
still blocking:
- re-run the same soft-nav axe check on d937659 at 1440 and 390, and list the actual aria-labels of the code regions on /docs/network/connect-your-tools/ after the nav. they should be readable, unique, and numbered from 1 on that page.
- refresh the PR body: the head line still says 4a135d3. add source.config.ts and src/lib/code-sample-label.mjs to "why each change", add the new test to the tests list, and add the npm run check result on this head.
passing looks like: those numbers on d937659, the body matching the head, and verify green. no reshoot needed, since the pixels don't change.
non-blocking: see the inline note on docs-code.tsx:56.
no collisions: #28 is the only open PR.
| if (!counter) { | ||
| throw new Error("DocsPre must render inside DocsCodeScope"); | ||
| } | ||
| counter.order += 1; |
There was a problem hiding this comment.
non-blocking: counter.order += 1 mutates shared state during render. React can render a DocsPre twice (StrictMode in dev, or a transition or Suspense retry) without re-rendering DocsCodeScope, which skips numbers ("bash code 2", "bash code 4") and adds false " 2" suffixes through used. passing looks like: stamp the page order at build time in the kimetsu-code-language transformer (for example a dataOrder property) and keep DocsPre a pure function of its props.
DocsPre only reads that order. A render-time counter could skip numbers when React renders a block twice. Co-authored-by: Rodrigo <rodrigo.ccordoba@hotmail.com>
RodCor
left a comment
There was a problem hiding this comment.
changes needed at 71117f6. one refresh, no code asks. verify is still running.
re-check of the last review:
- fixed at d937659: blocker 1 (soft-nav axe 0 violations at 1440/390, label list 1-11 readable and unique) and blocker 2 (body files, tests, npm run check).
- fixed at 71117f6: the non-blocking note. source.config.ts stampCodeOrder stamps dataOrder and dataCodeLabel at build time, DocsCodeScope and the render-time counter are gone, and DocsPre is a pure function of its props. tests pin it (no usePathname, no
+=, stampCodeOrder in source.config.ts). nice.
still blocking:
- the body's evidence is from d937659, and 71117f6 changes how every code-region label is built (rehype plugin instead of a client counter). re-run the same soft-nav check on 71117f6 at 1440 and 390: list the aria-labels of the code regions on /docs/network/connect-your-tools/ after the sidebar click, plus the axe violations/incomplete table. they should match the d937659 list (bash code 1 to bash code 11).
- refresh the body: head line says d937659. add stampCodeOrder to the source.config.ts note, say DocsCodeScope is gone, and add the npm run check result on 71117f6.
passing looks like: those numbers on 71117f6, the body matching the head, and verify green. no reshoot needed, the pixels don't change.
no collisions: #28 is still the only open PR.
RodCor
left a comment
There was a problem hiding this comment.
approved at 71117f6. soft-nav evidence is on this head: marker survives the sidebar click, axe 0 violations / 0 incomplete at 1440 and 390 on fresh load and after nav, labels bash code 1 through bash code 11. body matches the head (stampCodeOrder, DocsCodeScope and render-time counter gone, npm run check exit 0, 55/55). verify green. no reshoot needed, docs clips unchanged. forwarding to chimu; mark it ready when you're set.
Docs chrome accessibility on top of
origin/main5617e30. Head71117f6063d5b3bd93f650e888d3baab87937cbf. No copy changes.Files
source.config.tssrc/app/docs/[[...slug]]/page.tsxsrc/app/docs/layout.tsxsrc/app/global.csssrc/components/docs-code.tsxsrc/components/docs-landmarks.tsxsrc/lib/code-sample-label.mjstests/docs-a11y-chrome.test.mjsWhy each change
src/app/docs/[[...slug]]/page.tsx(judged): fumadocs props re-render with the page.DocsPagetakesrole="main".tableOfContent.containeris a navigation labeled "On this page".tableOfContentPopover.containeris a navigation labeled "Page sections".preisDocsPre.source.config.ts(judged): thekimetsu-code-languagetransformer copies the fence language and title onto each block.stampCodeOrderthen writesdataOrder, starting at 1 for that file, and the readabledataCodeLabel. The number is fixed at build time, so a React retry cannot skip it.DocsCodeScopeand the render-time counter are gone;DocsPrereads the stamped label from its props.src/lib/code-sample-label.mjs(judged): the label is the title when the block has one, otherwisebash code 1orCode sample 1. It strips«,», and:.src/components/docs-code.tsx(judged):DocsPreonly reads those props and passesviewportProps["aria-label"]. It does not count during render.src/components/docs-landmarks.tsx(judged): the mobile contents control is a<header>with no prop. A header stays a banner until its own role changes, so this setsrole="group"inuseLayoutEffectwith[pathname].src/app/docs/layout.tsx(judged): mount that effect from the docs layout.src/app/global.css(measured):#6A737Dis 3.65:1 on#191919. The rule sets it to#8b949e, and matches both--shiki-dark:#6A737Dand--shiki-dark: #6A737D.tests/docs-a11y-chrome.test.mjs(measured): pins the fumadocs ids, the comment-color rule, the props, the build-time order, and the label text.Code labels after a sidebar click (measured)
Same list at 1440 and at 390, on a fresh load and after the soft navigation. They are readable, unique, and numbered from 1. None contain
«,», or:.bash code 1bash code 2json code 3bash code 4toml code 5bash code 6json code 7bash code 8text code 9bash code 10bash code 11Soft navigation (measured)
axe-core 4.14.1, default
axe.run(document),devicePixelRatio1, on head71117f6. Servednpm run buildwithnpx serve out. Each width is its own page: load/docs/at that width, open Kimetsu Network (and the sidebar button at 390), setwindow.__navMarker = "alive", then click the sidebar link to/docs/network/connect-your-tools/.At 1440 and at 390 the marker was still
"alive"after the click.performance.getEntriesByType("navigation")stayed one entry of typenavigate. The URL was the connect page.Screenshots (measured)
The fresh-load docs clips at 1440 and 390, and the homepage code card, are byte-identical to the after screenshots already pinned. They still match this head visually. They were not retaken.
Before is
origin/main5617e30. After is this head's fresh load.Assets, pinned: 676c539
innerWidthHomepage comment color (measured)
The override does not reach the homepage code block. That block is
<pre class="km-install-command"><code>, not Shiki. Computed style of#get-started codeon this head: colorrgb(235, 235, 235), backgroundrgb(25, 25, 25), contrast 14.75:1. The homepage PNGs are byte-identical.Docs comment contrast (measured)
Before this change,
#6A737Don#191919is 3.65:1. After a fresh load, the computed color isrgb(139, 148, 158)(#8b949e) onrgb(25, 25, 25), which is 5.72:1.axe-core on main (measured)
Connect your tools on
main:color-contrastlandmark-one-mainlandmark-uniqueregioncolor-contrastlandmark-no-duplicate-bannerlandmark-one-mainlandmark-uniqueregionHomepage violations: 0 on
mainand on this branch, at 1440 and at 390. Incompletecolor-contraststays at 11 nodes. No new homepage violations.Tests (measured)
pins the fumadocs ids the docs chrome fix depends onpins the dark Shiki comment color overridesets docs landmark roles through fumadocs propsbuilds readable code labels without screen-reader id marksreapplies the uncovered header role when the docs path changesnpm run check(measured)Exit 0 on this head. Biome reported no fixes.
tsc --noEmitpassed.node --testpassed 55/55.next buildfinished andscripts/check-static-output.mjsverified 11 static routes.