Add visible focus indicator for app bar #968
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds visible focus indicator for app bar. Internal bug: b/277818573
The app bar's background color is #0C2D48. The focused tab color is #746EA1. The color contrast is 3.02.
Disclaimer: This was the best fix I could find but is not necessarily ideal. I'd appreciate feedback on this change, but may need pointers on how to wrangle the components.
With this change, the focus indicator is now present for keyboard and mouse users. However, the active tab's background is focused even after clicking, because the class ".mdc-ripple-upgraded--background-focused" remains on the clicked element. From what I could tell, the ripple effect was disabled to prevent that from happening, but it also removed visible focus indicators on the app bar altogether.
Regarding an accessibility issue in RMWC
Looking into this bug also made it apparent that we shouldn't use RMWC's Tabs because it creates a confusing experience for people using screen readers. Specifically, it changes tabindex's to -1 when you select away from tabs. For instance, say that you have 3 buttons "Cookies", "Pizza" and "Chocolate". The following would occur:
Default state: "Cookies" tabindex=0, "Pizza" (unset tabindex), "Chocolate" (unset tabindex)
After selecting "Pizza" tab: "Cookies" tabindex=-1, "Pizza" tabindex=0, "Chocolate" (unset tabindex)
Then selecting "Chocolate" tab: "Cookies" tabindex=-1, "Pizza" tabindex=-1, "Chocolate" tabindex=0
Then selecting "Cookies" tab: "Cookies" tabindex=0, "Pizza" tabindex=-1, "Chocolate" tabindex=-1
After the above interactions with the page, a screen reader user wouldn't be able to use the keyboard to get to the "Pizza" and "Chocolate" tabs. You can see this example by interacting with their docs page https://rmwc.io/tabs.
Screenshots and images demonstrating the changes from this PR:
Shout out to maneesht for debugging this one with me; couldn't have gotten to this state w/o his help