-
Notifications
You must be signed in to change notification settings - Fork 0
focusDisplayHandler
Mike Byrne edited this page Jan 25, 2022
·
2 revisions
Adds data-focus-method
to document.activeElement
which differentiates between keyboard, mouse and touch focus - values of which can be touch
, key
or mouse
. This allows you to style keyboard focus events and hide the focus ring for mouse events (because designers hate those!)
- setFocusOnTarget (handled automatically)
- none
- nothing
Setup:
import { focusDisplayHandler } from './functions'
document.addEventListener('DOMContentLoaded', function(){
// workout focus type
focusDisplayHandler();
});
In your CSS:
:focus[data-focus-method="mouse"],
:focus[data-focus-method="touch"] {
outline: none !important;
}