ten1seven / what-input

A global utility for tracking the current input method (mouse/pointer, keyboard or touch).
https://ten1seven.github.io/what-input
MIT License
1.35k stars 89 forks source link

[data-whatintent='mouse'] *:focus does not apply to <a> and <button> elements #81

Closed mbdoch closed 6 years ago

mbdoch commented 6 years ago

Hello!

The following css has different effects in different browsers:

[data-whatintent='mouse'] *:focus {
  outline: none;
}

Have I missed any step to make it work in all of them? Thanks!

ten1seven commented 6 years ago

@mbriantoc that should do it, but this code snippet doesn't give me much context around what's happening in your app. I can give you two things to try in those browsers:

Make sure the JavaScript is loading and working

Open your browser's developer tools so you can inspect the markup as you interact with the page.

Isolate your CSS from what should work

Let me know what you find!

mbdoch commented 6 years ago

Hi @ten1seven

Thanks for the hints!

I was comparing the behaviour of your demo and my app (which is an AngularJS app btw) and the only difference I found is that, in my app, when clicking on any element, the data-whatclasses attribute appears with the value of the element's classes.

Is that expected?

ten1seven commented 6 years ago

Correct! data-whatclasses displays the classes of the focused (or clicked) element so that you can do very specific styling if desired, like:

[data-whatintent="mouse"][data-whatclasses*="my-class"] .parent-of-my-class {
   /* special styling because I know that .my-class was interacted with */
}
mbdoch commented 6 years ago

Hi @ten1seven

I found out we have a mixin dealing with the style when focus is on the links in the navigation. That's why it didn't work for the elements.

The lib works just fine! Thanks a lot :)

ten1seven commented 6 years ago

Great to hear!