-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Link] Improve accessibility of focus styles #1425
Conversation
I see the proposed solution to be sub-optimal (as mentioned above), but considering the state of CSS in 2019, it's probably the most appropriate way to achieve the intended results today. The future is promising, though! Suggestions for the long termSome pretty cool CSS pseudo-classes are coming as part of the CSS Selectors level 4 spec. For reference, I thought I'd mention them in this issue. 2020?
|
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 good to me. I tested in Firefox and Edge as well, including in High Contrast for Edge, and with text resizing. Everything works as I'd expect from the defaults!
We should probably prepare a statement about why we've decided to do this, since I expect that we'll get some complaints about it being "ugly".
Good idea @dpersing! I drafted an explanation which we can jam on here: https://docs.google.com/document/d/17uH9fLWPN7ENugsQ1C91I_9izodqd_wR2U5Lcb_9B20/edit?usp=sharing |
047267b
to
a2c09ff
Compare
I checked the style guide and I don’t think this needs any component documentation updates. Going to ship when everything goes green 🍏 |
This PR also fixes https://github.com/Shopify/polaris-ux/issues/242! |
@sarahill I realized I never answered your question about why browser defaults are sub-optimal. There’s a couple of reasons in my opinion:
|
Im optimistic we can bake a few universal, accessible, custom focus styles into the next style guide iteration! |
@ry5n Thanks for the reply! I dug into it a bit more after I asked the question too. I found pretty much the same things you stated above. This'll be a good one to see evolve. Nice work, Ryan 🎉 |
Looking good! |
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.
👍
WHY are these changes introduced?
Fixes https://github.com/Shopify/polaris-ux/issues/40 and https://github.com/Shopify/polaris-ux/issues/156
Original design
In the original issues, we landed on some more accessible focus styles for links:
Implementation challenges
In implementing these, however, I ran into some problems. The main one is that if
Link
remains styled as an inline element, image links look bad out of the box:We could fix this by making all images in Polaris block-level by default. This is usually what you want, but may have knock-on effects in consuming apps. Another way would be to set links to be
inline-flex
, but has similar risks for existing apps.Current approach: go with browser defaults
To avoid breaking changes, I’ve opted to go a different route from the original designs and strip back to browser default styles instead.
Here’s how things look now in different browsers. I left out iOS Safari since I haven’t been able to get the external keyboard emulation working in order to visualize element focus.
Chrome (Android)
Chrome (Mac)
Safari (Mac)
Edge (Windows)
Firefox (Mac)
How to review
My big question is: are we OK moving forward with this approach? It’s not ideal, but it’s also a big improvement on the inaccessible styles we have today.
Please give feedback based on either the screenshots attached, or 🎩using the playground below:
Copy-paste this code in
playground/Playground.tsx
:Next steps
If we’re OK with this experience, I’ll update documentation and changelog and ship. We can then consider what larger changes we’d want to make to Polaris’ foundations to support a better implementation/breaking change later.
🎩 checklist
README.md
with documentation changes