-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add "Skip to main content" link and update nav behavior #2253
Conversation
Allows skip link text to be updated dynamically based on the route path. See docisfy site’s “Translations” menu as an example of why this is necessary.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Co-authored-by: Joe Pea <[email protected]>
# Conflicts: # src/core/render/index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can not show the btn locally or on the vercel Preview
, although the dom is insert success.
Is there any style issue?
@Koooooo-7 -- TL;DR: Press Tab after the initial site load.
Or...
The Vercel preview is working correctly. The "Skip to main content" link is intended to be the first "focusable" element in the DOM. It is hidden by default and only visible when it receives focus. The intention is for it to be hidden for visitors navigating with a pointing device, but easily accessible to keyboard navigators and assistive device users by pressing Tab after the initial site load. If you are wondering why pressing Tab does not result in the skip link being displayed after subsequent page loads, the following explanation taken from this comment explains:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good jobs!
Hi @jhildenbiddle , sorry for the misunderstanding here. Based on our site here, about the |
No worries, @Koooooo-7. Happy to hear it's working as expected for you!
👍 I've made a small update to the PR. Focus will now move to the linked heading when loading a URL with a linked heading A complete summary of the new navigation behavior is available in the summary and below:
Given the above behavior, I believe your concerns are addressed:
In both scenarios above, pressing Tab will not display the skip link. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thx @jhildenbiddle for you ideas and contributions. 👍
# Conflicts: # src/core/render/index.js # src/core/render/tpl.js
Would you mind approving this PR again? I had to merge |
Summary
These updates align with accessibility best practices. The skip link and the updated navigation behavior allow for more efficient navigation via the keyboard and screen readers.
id
, focus will remain on the<body>
element. This is the browser's default behavior, which allows the skip link to appear when visitors press Tab one time.id
, focus will be moved to the linked heading.skipLink
configuration optionsThis bug also addresses a separate issue where caused Docsify to treat successfully loaded but empty markdown files as 404 errors.
Related research
Screenshots
Safari 17 on macOS 14.0
Related issue, if any:
#494
#495
#2294 (Fixes loading of empty markdown files)
What kind of change does this PR introduce?
For any code change:
Does this PR introduce a breaking change?
No
Tested in the following browsers: