Redocly / Redocly/redoc

Use actual anchors for TOC links for better accessibility

Open
#1,090 0 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

a11y
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Currently the TOC in the sidebar uses <label> and the route change is applied on click. It'd be better if the links are actual anchor links for accessibility reason. Users can then share direct links to different parts of the documentation.

image

The issue I'm facing currently is that with SSR and when the site is hydrating on the client side, the TOC links are not operational as the event handlers are still being registered.

With the change proposed above, the site would be still operational even without JavaScript.

Here's an example on how Slate does it - https://slatedocs.github.io/slate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sidebar TOC implementation and compare its current label-and-click route behavior with the linked Slate example. Done means TOC items use actual anchors, direct section links work during SSR hydration and without JavaScript, and accessibility is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
accessibility, documentation, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.