You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least on Chrome we have those blue focus rings around buttons and form elements. They are important for keyboard navigation but I find them horrific to look at.
What I usually do is to disable them and only once a user tabs I turn them on. This would look something like that:
/* In the CSS file we disable the focus rings */body:not(.user-is-tabbing) button:focus,body:not(.user-is-tabbing) input:focus,body:not(.user-is-tabbing) select:focus,body:not(.user-is-tabbing) textarea:focus {
outline: none;
}
// In the React root we look out for the first tab event.constApp=()=>{const[firstTabHandled,setFirstTabHandled]=useState(false);// enable form focus rings when tabbinguseEffect(()=>{if(firstTabHandled)return;consthandleFirstTab=(ev: KeyboardEvent)=>{// the "I am a keyboard user" keyif(ev.key==="Tab"){document.body.classList.add("user-is-tabbing");window.removeEventListener("keydown",handleFirstTab);}};window.addEventListener("keydown",handleFirstTab);setFirstTabHandled(true);return()=>window.removeEventListener("keydown",handleFirstTab);},[firstTabHandled]);return<div/>;}
@aeluteia, @ana0 how do you feel about that? Shall we implement that?
The text was updated successfully, but these errors were encountered:
At least on Chrome we have those blue focus rings around buttons and form elements. They are important for keyboard navigation but I find them horrific to look at.
What I usually do is to disable them and only once a user tabs I turn them on. This would look something like that:
@aeluteia, @ana0 how do you feel about that? Shall we implement that?
The text was updated successfully, but these errors were encountered: