.visually-hidden-focusable should also apply to :focus-within
See original GitHub issueCurrently the visually-hidden-focusable
class only shows elements which are directly focused.
It is however rather common to have a single hidden element which contains two or more anchors to skip to content, navigation, footer etc.
As it is right now this is rather cumbersome and requires manual styling/classes.
Changing the class to also show elements when the focus-within
pseudo-class applies should not break things and simplifies this a lot.
The only cases where this would break stuff is if one was using nested focusable elements (e.g. a link inside a button - which I don’t even know if something like that is allowed) and depends on the behaviour that focusing the element would hide and therefore unfocus both of them.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Visually hidden
Use .visually-hidden-focusable to visually hide an element by default, but to display it when it's focused (e.g. by a keyboard-only user) ...
Read more >visibility:hidden - focus test
Hidden elements - focus test. These buttons are hidden in different ways. Let's see if they are focusable! Even-numbered buttons are hidden using...
Read more >Visually hidden
Use .visually-hidden-focusable to visually hide an element by default, but to display it when it's focused (e.g. by a keyboard-only user) ...
Read more >Bootstrap 5 Visually hidden
The visually-hidden-focusable class can also be applied to a container by using :focus-within, the container will be displayed when any ...
Read more >The 'visually-hidden' technique. Sometimes you want to ...
Some people use the tab key to navigate across focusable elements on a webpage. Such sighted keyboard users get puzzled when a “visually-hidden”...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i think keeping the same class wouldn’t be a problem, as long as it’s properly documented. giving this a whirl to see how it ends up…
I really like it, and as @septatrix said, there shouldn’t be any side-effect if there’s no nested focusable elements.