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

Global :focus { outline: none; } reset declaration and Polyfill concerns #8

Closed
joe-watkins opened this issue Mar 24, 2017 · 7 comments

Comments

@joe-watkins
Copy link

joe-watkins commented Mar 24, 2017

Hi :)

Per the documentation, I'm really struggling with the blanket :focus { outline: none; } code recommendation. I want to be on board with this awesome feature but feel like we could come up with something better.

It is very bold to say hey.. attention all browsers - kill all outlines on focusable elements and then rely on JS to fill the gaps or when implemented only supporting browsers will overwrite that rule. Many older browsers support :focus {} but will not support :focus-ring ever.

Some ideas

Here are some ideas instead of just a global :focus { outline: none; }

  1. For the spec: lean on fault tolerance so browsers that don't understand skip it?:

:not(:focus-ring) :focus { outline: none; }

  1. For the Polyfill have JS add a class to html tag and descend from that:

.focus-ring-polyfill :focus:not(.focus-ring) { outline: none; }

This would mean JS is probably present, loaded, no errors, and the Polyfill should work.

I don't want to be a stick in the mud but we are working hard out here trying to get folks to stop killing outlines for many different accessibility-related reasons.

Consider these personas:

Lisa: I use my Dell laptop I'm a mouse user, touch user, and a keyboard user. I have a cognitive related disability that affects my memory and have low-vision it's important for me to have an understanding of where I am in the interface -- and yes even right after I click on something. I don't always use a screen reader. I may start a web form using a keyboard and then click on something and I get confused when the focus ring is removed from the UI.

Paul: I turn JavaScript off because it ensures my browsing experience does not have too much animation. I'm epileptic, have low vision, and very sensitive to animation and flashing. I'm also a keyboard user and mouse user. Because of this I turn the brightness down on my screen. I have difficulty getting around a site when they don't have focus states.

@robdodson
Copy link
Collaborator

Thanks for the issues and pull requests. Myself and Alice have been traveling and out sick so we're catching up on things. Didn't want you to think that lack of a response meant we were ignoring you!

@jonathantneal
Copy link
Contributor

These are great observations, @joe-watkins. Here is my train of thought on the matter:

In Media Queries Level 4 or 5, we can check for scripting:

@media (scripting: enabled) {
  :focus:not(.focus-ring) {}
}

But if :focus-ring ships first, it doesn’t matter. So, for now, we can use the .js cowpath:

.js :focus:not(.focus-ring) {}

But that increases selector weight. Err..

So, what if the polyfill provided 2 focus classes?

.js-focus {}
.js-focus-ring {}

This might preserve selector weight and protect non-js experiences. Thoughts?

@robdodson
Copy link
Collaborator

After discussing this with Alice I think we're going to go with the approach of adding a class to the body to indicate that JS is working and the polyfill has been loaded properly. This should also address #6

@joe-watkins
Copy link
Author

@robdodson Sweet!

@jonathantneal
Copy link
Contributor

@robdodson, will it increase selector weight?

@stefanjudis
Copy link
Contributor

stefanjudis commented Aug 10, 2017

Hmm.. @robdodson this can be closed now or? It looks like I messed up the auto issue closing. :)

@robdodson
Copy link
Collaborator

yep we can close it. Although I do kinda like the suggestion of using the .js-* prefix. I think that's a common convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants