Skip to content
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

fix(v2): make more accessible skip link #4162

Merged
merged 1 commit into from
Feb 3, 2021
Merged

fix(v2): make more accessible skip link #4162

merged 1 commit into from
Feb 3, 2021

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Feb 2, 2021

Motivation

Should fix #3917

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Preview https://deploy-preview-4162--docusaurus-2.netlify.app/classic/

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 added the pr: bug fix This PR fixes a bug in a past release. label Feb 2, 2021
@lex111 lex111 requested a review from slorber as a code owner February 2, 2021 22:47
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 2, 2021
@facebook facebook deleted a comment from netlify bot Feb 2, 2021
@facebook facebook deleted a comment from netlify bot Feb 2, 2021
@github-actions
Copy link

github-actions bot commented Feb 2, 2021

Size Change: +18 B (0%)

Total Size: 156 kB

ℹ️ View Unchanged
Filename Size Change
website/build/assets/css/styles.********.css 17.7 kB 0 B
website/build/assets/js/main.********.js 109 kB +14 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 21.7 kB +3 B (0%)
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 6.95 kB +1 B (0%)

compressed-size-action

@github-actions
Copy link

github-actions bot commented Feb 2, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 89
🟢 Accessibility 99
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4162--docusaurus-2.netlify.app/classic/

@slorber
Copy link
Collaborator

slorber commented Feb 3, 2021

Thanks @lex111 !

@Mythra can you please tell us if the "skip to main content" link works better for you now?

Testing on this URL: https://deploy-preview-4162--docusaurus-2.netlify.app/classic/

As a side note this button currently only activates if "enter" is pressed. This is problematic as Enter can most often be taken elsewhere. The space bar natively works for button's normally, or synthetically inject clicks. So have onClick/space not work can create a very frustrating experience, and may make it impossible to click.

Not sure to understand 100% what you mean here, should we make that link (replaces the button) lead to the main content when space is pressed?


I think this PR improves the issue you had, as we now use a link, and it actually gives the focus ring to the main content, so I'm going to merge, but feel free to re-open/comment if this does not work for you

@slorber slorber merged commit 3f6e043 into master Feb 3, 2021
el.setAttribute('tabindex', '-1');
el.focus();
setTimeout(() => el.removeAttribute('tabindex'), 1000);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know this was possible, nice trick
is it safe in all cases to use? (seems to work for Chrome + Safari at least)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, it's safe.

@lex111 lex111 deleted the lex111/iss3917 branch February 3, 2021 16:30
@Mythra
Copy link

Mythra commented Feb 3, 2021

Hey,

Thanks for doing the work here, was looking forward to doing it myself/reviewing it, but hey as long as it gets done.

As for the tabindex trick it is useful for Safari, but is there a particular reason removing tabindex is set to a delay of 1 second, Rather than just using a setTimeout of 0 so it happens on the next visual tick? It might be weird for a user who is tabbing in that second to be on an element, and all of a sudden have that element just not be a core focus anymore. I hit it once accidentally before looking at the code, but I was more testing everything was working. Hard to say how many people would hit it in practice.


Not sure to understand 100% what you mean here, should we make that link (replaces the button) lead to the main content when space is pressed?

@slorber as long as it's a link you don't need to have the space key function. The problem I was outlining there was having a "button" element specifically, not reacting to space. As long as it's a link (which is more correct) we don't need the space key to work. It's just when me, and other screen-reader users here "button" we expect space to work as by default it does.

And FWIW I'm happy to provide reviews on a11y issues, so we don't merge in broken examples like we did with this. Where it was done in good faith, just no one was sure how to test it. Always better to ask and wait a bit than ship a broken experience I think 😉

But thank you both, tons! Glad to see it get fixed!

@lex111
Copy link
Contributor Author

lex111 commented Feb 3, 2021

@Mythra thank you too for letting us know! We will be glad if you find any more issues related with a11y, we will try to fix them!

As for the tabindex trick it is useful for Safari, but is there a particular reason removing tabindex is set to a delay of 1 second,...

Indeed, this is not a very good experience, maybe it is worth turning off the outline on the main element (by adding outline: none)? After all, this element are not accessible from the keyboard, so it will be safe action, what do you think? Or is it enough to just remove any delay (setTimeout)?

@Mythra
Copy link

Mythra commented Feb 3, 2021

I'd say let's not override the outline behavior that the browser , if the browser wants to outline it let's let it do that (even though I don't think it should with 0). I think setting to 0 would help people tabbing through fast, so definitely I'd be for that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skip to Content Link is woefully incorrect
4 participants