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
Skip links are not the first focused element on internal navigation #13505
Comments
|
Thanks for the issue, we will take it into consideration! Our team of engineers is busy working on many types of features, please give us time to get back to you. Feature requests that require more discussion may be closed. Read more about our feature request process on forem.dev. To our amazing contributors: issues labeled To claim an issue to work on, please leave a comment. If you've claimed the issue and need help, please ping @forem/oss. The OSS Community Manager or the engineers on OSS rotation will follow up. For full info on how to contribute, please check out our contributors guide. |
|
I think the easiest solution, though I'm sure you've already thought of this, is to modify the header to be a focusable element.
<header tabindex="-1" class="crayons-header crayons-focus-reset print-hidden">
content...
</header>.crayons-focus-reset:focus {
outline: none;
}Then when you load in a new page you set the focus to document.querySelector('.crayons-focus-reset').focus(); |
|
I'm keen to run with the results from the research linked above, and focus the skip link after the route change, but I agree if there proves to be any difficulty doing that, focusing the header could be the next best thing 👍 |
|
Hello! 👋 I'd like to work on this, if that's alright. |
|
Sounds good @metamoni! Assigning this to you. |
|
@metamoni yes!! excited to have you here 😄 ✨ |
|
@aitchiss I've played with quite a bit this over the weekend and here's what I've done:
document.querySelector('.skip-content-link').focus()
&:focus:not(:focus-visible) {
visibility: hidden;
}
&:focus-visible {
pointer-events: auto;
transform: translate(-50%, 0);
outline: none;
border: 2px solid var(--header-button-focus-color);
}Here's what that looks like: It mostly works the way you wanted, except the Skip Link gets focused automatically when the page is loaded/reloaded. Any idea how to handle this from here? The way I see it, to fix this we'd probably need something in place for when the window loads, i.e. focus on an empty element (or the header) and only go to the Skip Link when the user presses Tab. Which would bring us back to the solution proposed by @Link2Twenty. Let me know what you think. |
|
@metamoni I'm wondering if we could get around this by adding your code to
The only thing I'm wondering is if this will play nicely with browser back press navigation 🙃 |
|
I'll investigate 🕵️♀️ |
@aitchiss, the |
Yeah you're right - it just occurred to me thinking about |
|
Your suggestion worked, @aitchiss. Finally got around to opening a PR for this. Thank you for your help and patience 🙂 |
|
Closed via #13828 ❤️ |
Describe the bug
Under #1153 we added skip links to all pages in the app. A skip link should be the first element focused on a page when the user presses the Tab key - however, this is only the case in a Forem if you land directly on a URL, and not if you navigate internally, e.g. by a link click.
There are several strategies available to managing focus on route change, but I would suggested the approach Marcy Sutton has written about following user testing with Fable: What we learned from user testing of accessible client-side routing techniques with Fable Tech Labs
The recommendation in that article is to send focus immediately to the skip link on the new page. We will need to experiment with
:focus-visibleto ensure that for users who navigated by mouse click, the skip link isn't visible. If this isn't possible, I think an acceptable fallback would be to focus an empty element directly before the skip link, so that once on the new page, the skip link is the first item focused on Tab press.To Reproduce
Expected behavior
The text was updated successfully, but these errors were encountered: