-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
.sr-only
& .sr-only-focusable
tweaks
#28720
Conversation
Using I think that the CC: @patrickhlauke |
8fd87c4
to
2f7a7f5
Compare
@MartijnCuppens: rebased. Please make any further changes if needed. |
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.
Conceptually, i like it - and prefer the fact that you don't have to double up/combine the sr-only
and sr-only-focusable
classes anymore, but just pick one. Not had time to test, but trust that if it does what it says on the tin, the approach is sound (modulo that thing about :not(:active)
2f7a7f5
to
8b48876
Compare
66b6c02
to
bc08373
Compare
I've also added a notice in the migration guide. @patrickhlauke, could you have a look if everything is ok now? |
Ping @patrickhlauke |
7cff7d4
to
9b6c882
Compare
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.
With exception of the tiny change request, everything else looks good to me and can be merged after change is made.
Analysis of the
.sr-only
properties:position: absolute
: needed to prevent the element from taking up space in the documentwidth: 1px
: prevents the element from becoming too wide and therefor creating scrollbarsheight: 1px
: prevents the element from becoming too tall and therefor creating scrollbarspadding: 0
: padding could increase the width or height even when those are set to1px
overflow: hidden
: prevent the text inside from breaking out the boxclip: rect(0, 0, 0, 0)
: make the element invisiblewhite-space: nowrap
: see #22154border: 0
: border could increase the width or height even when those are set to1px
So yeah, we all need them.
We had this problem: #28691, which could be fixed by adding
!important
to all properties, but that would just make this problem bigger: https://codepen.io/MartijnCuppens/pen/Pgrpwe.And than I remembered a technique I used before (#25806), just make use of the
:not()
selector. This would solve #28691 without introducing padding issues.This would also not require the
.sr-only
class on elements with.sr-only-focusable
. I've changed the docs a bit to make this clear.I added @Jakobud as co author for the
!important
commit since he already fixed that in #28701.Fixes #28691
Closes #28701