-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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: add support for :focus-visible selector #5483
Fix: add support for :focus-visible selector #5483
Conversation
"The PR doesn't break other browsers" - is that true? Doesn't this PR disable focus outlines if We can't do that and break accessibility across all browsers except Chrome with an Experimental flag enabled. I thought this PR was going to integrate the |
Hi Owen, Thanks for the comment. I created also codepen demo example here: |
Owen Edwards <[email protected]> 於 2018年10月8日週一 6:44 寫道:
… "The PR doesn't break other browsers" - is that true? Doesn't this PR
disable focus outlines if :focus-visible is not present, so it will
disable the outline for *all* browsers *except* Chrome with *"Experimental
Web Platform features" under the Chrome settings (chrome://flags/)"*
enabled?
We can't do that and break accessibility across all browsers except Chrome
with an Experimental flag enabled. I thought this PR was going to integrate
the ":focus-visible" polyfill.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5483 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AeI8rr-nlpGGZR_XB8hA6kcmJuBY2_6qks5uioPrgaJpZM4XLBGZ>
.
|
What about a general one in the main scss file instead for each component? .video-js *:focus:not(:focus-visible) {
outline: none;
} @OwenEdwards older browsers that don't support that pseudo-selector will ignore the entire block. |
@gjanblaszczyk and @gkatsev: "older browsers that don't support that pseudo-selector will ignore the entire block." - ahh, thanks for that clarification, I misunderstood that. Then I agree with @gkatsev's suggestion above, making it generic for all of video.js. Additionally, I'd suggest that we add the |
Thanks for comments, |
Adding a |
You can go to this URL directly |
@gjanblaszczyk hey, did you get a chance to add the example page using the polyfill? |
Hi @gkatsev, not yet but I am planning to do that tomorrow. |
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.
Thanks for the update
sandbox/focus-visible.html.example
Outdated
This will hide the focus indicator if the element receives focus via the mouse, | ||
but it will still show up on keyboard focus. | ||
*/ | ||
.js-focus-visible :focus:not(.focus-visible) { |
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.
is this piece necessary since we have a similar one in Video.js now?
sandbox/focus-visible.html.example
Outdated
<body> | ||
<div style="background-color:#eee; border: 1px solid #777; padding: 10px; margin-bottom: 20px; font-size: .8em; line-height: 1.5em; font-family: Verdana, sans-serif;"> | ||
<p>You can use /sandbox/ for writing and testing your own code. Nothing in /sandbox/ will get checked into the repo, except files that end in .example (so don't edit or add those files). To get started make a copy of index.html.example and rename it to index.html.</p> | ||
<pre>cp sandbox/focus-visible.html.example sandbox/focus-visible.html</pre> |
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.
we really need to update this text, npm start
will automatically copy these files over from .example if they don't already exist.
sandbox/focus-visible.html.example
Outdated
<video id="vid1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264" | ||
poster="http://vjs.zencdn.net/v/oceans.png" | ||
data-setup='{"controlBar": {"volumePanel": {"inline": false}}}'> | ||
<!-- <source src="http://wms.shared.streamshow.it/canale8/canale8/playlist.m3u8" type="application/x-mpegURL"> --> |
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 this line be removed?
Looks like the package-lock hasn't been updated, can you update it with npm 6.4.1? |
src/css/video-js.scss
Outdated
@@ -52,3 +52,7 @@ | |||
border: none; | |||
visibility: hidden; | |||
} | |||
|
|||
.video-js *:focus:not(.focus-visible) { |
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.
does the polyfill require the usage of the .focus-visible
class? We probably want to have both selectors in that case.
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.
Yes, according to the polyfill doc. This class is needed.
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.
Ah, cool, didn't realize. Yeah, let's just do both, then eventually we can remove this one. Thanks!
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.
If you're going to do this (which makes sense because the focus-visible polyfill can only apply a .focus-visible
class, not a :focus-visible
pseudo-class, I think you need to include the syntax I had in my example:
.js-focus-visible .video-js *:focus:not(.focus-visible) {
outline: none;
}
Without the .js-focus-visible
it's going to remove the focus outline if the developer doesn't include the polyfill, which is exactly what we want to avoid.
For example, see https://deploy-preview-5483--videojs-docs.netlify.com/test-example/index.html and use keyboard-only operation.
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.
^^^ That comment should have been a review
Actually, it's weird but I'm not seeing the outline when using the keyboard which is kind of weird. I'd expect to still see it then. |
Aah, makes sense. Totally missed that. I guess either swap it out for <script src="https://unpkg.com/focus-visible"></script> or edit the build file https://github.com/videojs/video.js/blob/master/build/generate-example.js The updating the url is probably easiest. |
Loading in the polyfill manually made it work beautifully. |
Great but maybe I should change the focus-visible polyfill script src to https://unpkg.com/focus-visible on the focus-visible example page and remove focus-visible polyfill from the node package.json file. I guess better to have less dependency. What do you think? |
Sounds good. |
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.
🎉
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.
See my note on the need for the .js-focus-visible
class in the CSS selector.
src/css/video-js.scss
Outdated
@@ -52,3 +52,7 @@ | |||
border: none; | |||
visibility: hidden; | |||
} | |||
|
|||
.video-js *:focus:not(.focus-visible) { |
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.
^^^ That comment should have been a review
Oh, yeah, I'll add it in when I merge if @gjanblaszczyk doesn't get to it first. |
Congrats on merging your first pull request! 🎉🎉🎉 |
Thanks @gjanblaszczyk! |
np @gkatsev |
Add support for focus-visible so that mouse-users don't need to see focus outlines but keyboard and Screen Reader users still do. It includes both the standard selector and the selector intended to work with the polyfill: https://github.com/WICG/focus-visible. The polyfill is *not* included in Video.js and must be included on the page separately. Fixes #5474.
Description
A proposed fix for #5474
It based on :focus-visible selector.
For now, it works only on Chrome. You have to enable "Experimental Web Platform features" under the Chrome settings (chrome://flags/) to be an able test this solution.
The PR doesn't break other browsers.
Requirements Checklist