Tweak .visually-hidden to use display:inline-block instead of absolute positioning#41474
Tweak .visually-hidden to use display:inline-block instead of absolute positioning#41474patrickhlauke wants to merge 2 commits into
.visually-hidden to use display:inline-block instead of absolute positioning#41474Conversation
|
I think this needs various test cases for when a visually hidden element is a flex or grid child, for example. Absolute position ensures context and flow would not be impacted, but I think switching to display could lead to layout changes. I'll try to pack some cases. |
|
thanks @ffoodd that'd be super helpful ... hoping that there won't be any unforeseen side effects here... |
|
I’m currently working on a CodePen aggregating every reduced test cases I can think of. But, FWIW, I also ran into #24906 which removed So, here's the reduced test cases collection on CodePen, using current 5.38 release and this PR's build. As I thought, there're edge cases when used as grid or flex children (checked on Firefox). IMHO this should not exist, but as it was possible until this change, we can fear that someone used it… At least, we now have a pen to play with! |
|
thanks for keeping the flame alive @ffoodd .. i know i've really been dropping off from my duties here, but ... life |
|
So, after a few minutes digging around:
I'm not sure that's all to be done, but that a first step :) |
…olute positioning
341589b to
55f4be7
Compare
|
I rebased the branch and pushed some more improvements:
The only edge case I couldn't deal with is when If I'm missing any case, feel free to fork the CodePen mentioned above to add your case. |
55f4be7 to
cdc89a0
Compare
Description
Use
display:inline-blockinstead ofposition:absolutefor.visually-hiddenMotivation & Context
While tried and tested, the regular
.visually-hiddenstyles have unintended consequences in certain scenarios, such as inside responsive tables - see #31885As the
position:absoluteis used essentially to force the element to accept explicitwidth/height/clipeven when it's currently inline, this new approach should have the same end result, but without causing any more accidental spacing.See the redone example from #31885 (replacing the old
.sr-onlywith.visually-hidden), with overrides that mimic the end result of this PR: https://codepen.io/team/bootstrap/pen/azzxqBZ (removing the overrides in the Pen's CSS shows the current broken behaviour: make the viewport/browser window narrow, and notice how - just like in the original #31885 issue - the visually hidden content in the last cell of the first row leads to whitespace to the right of the table that then results in a page-level horizontal scrollbar)Suggest extensive testing of this, to make sure the change doesn't now cause other unintended consequences elsewhere. Suggest also testing on devices that are notoriously flaky ... like "does it work as expected on iOS/Safari with/without VoiceOver running".
Marking as a breaking change because it has the potential to break things if an author did heavily rely on the old styles for some reason.
Type of changes
Checklist
npm run lint)Live previews
Related issues
#31885