Keep focus on sidebar links after navigation#2740
Open
puneetdixit200 wants to merge 1 commit into
Open
Conversation
|
Someone is attempting to deploy a commit to the Docsify Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
paulhibbitts
reviewed
Jun 5, 2026
Member
paulhibbitts
left a comment
There was a problem hiding this comment.
Thanks very much for this helpful PR @puneetdixit200 !
My knowledge of accessibility is quite basic - I used the following steps to test your PR:
- Open PR preview
- Use the TAB key to step through elements of the user interface, stoping on a navigation item in the Sidebar
- Use the RETURN key to activate selected link and display relevant content
- Using the TAB key stop on a second navigation item in the Sidebar
- Use the RETURN key to activate the second selected link and display relevant content
Doing the above I see that the selected Sidebar item keeps focus - please confirm this is a valid test of the changes you submitted. Thanks again, Paul.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keeps keyboard focus on the activated sidebar link after Docsify finishes rendering the destination route.
For hash-mode navigation, the router now carries the original link click event through the
hashchangecallback. The event layer uses that clicked sidebar link to focus the matching link in the freshly rendered sidebar instead of moving focus to the main heading, whose programmatic focus is intentionally visually hidden.Related issue, if any:
Fixes #2600
What kind of change does this PR introduce?
For any code change,
Does this PR introduce a breaking change?
Tested in the following browsers:
Verification run:
npm run buildnpx playwright test test/e2e/sidebar.test.js --project=chromiumnpm run test:unitnpm run lintgit diff --check