Change the way focus is set in skip link example code #3164
+8
−4
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.
Description of Problem
The example code in the skip link section of the accessibility best practices documentation, resets the focus to the skip link every time the route changes. This brings the link into focus and shows it every time. This is technically functional, but defeats the purpose of hiding it with CSS, and doesn't match the behavior on the documentation website itself (or a few others I checked, like Wikipedia, github, w3.org). If the goal is to replicate the way regular web page navigation would affect the focus, then it should be reset to somewhere directly before the skip link.
Expected behavior: On a route change, the skip link is hidden, and when you press tab it appears and is focused.
Actual behavior: On a route change, the skip link is visible and focused. Pressing tab moves the focus to whatever the next element is.
Also, in the current example code the skip link list still has visible bullet points, so I added some CSS to hide those.
Proposed Solution
The Vue theme sets the focus to a
backToTop
<span>
element directly before the skip link. This way the skip link will only ever be focused if someone presses tab just after there is a route change. This seems to be more in line with what most web pages with a hidden skip link do.Additional Information
For easy reference, WCAG skip link success criteria