-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Display outline on control buttons when focused #8520
Conversation
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.
This looks and works great!
@ryanhamley I agree, your solution looks better. 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.
Looks good to me, me pending lint fixes. One thing to note is that the outline will now appear when you click on the buttons with a mouse, but that's probably OK.
I fixed the lint issue and added a couple new rules that will only display the outline when the buttons are focused by keyboard input using the |
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.
🍏 I didn't know about focus-visible
but it totally makes sense to use it, because it adheres to the principles of progressive enhancement — browsers that support it will get enhanced experience while browsers that don't are still fully functional.
|
||
.mapboxgl-ctrl-group > button:focus-visible { | ||
box-shadow: 0 0 2px 2px rgba(0, 150, 255, 1); | ||
} |
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.
Nit: you can group these two selectors.
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.
I actually can't because I just realized Firefox uses the -moz-focusring
selector instead of focus-visible
so combining them makes the entire rule invalid in Firefox which breaks all focusing on the buttons. It turns out that Firefox and Safari don't appear to register clicks as focusing the button so they just work without this rule. I'll still leave it though because it's a progressive enhancement in Chrome and presumably newer versions of Edge.
Launch Checklist
Fixes #8246
outline
property because outlines do not follow rounded borders.box-shadow
does follow rounded borders, leading to a cleaner looking UI while simulating the outline effect (not sure why the GIF is so slow but you get the idea)