<Collapse /> does not apply aria-hidden="true" to not rendered component
See original GitHub issueWhen using <Collapse />
, items not rendered are not appropriately marked with aria-hidden="true"
causing accessibility issues.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
<Collapse in={true}>
<div>Child of visible collapse</div>
</Collapse>
<Collapse in={false}>
<div>Child of hidden collapse</div>
</Collapse>
Renders to:
<div class="MuiCollapse-container MuiCollapse-entered" style="min-height: 0px;">
<div class="MuiCollapse-wrapper">
<div class="MuiCollapse-wrapperInner">
<div>Child of visible collapse</div>
</div>
</div>
</div>
<div class="MuiCollapse-container MuiCollapse-hidden" style="min-height: 0px;">
<div class="MuiCollapse-wrapper">
<div class="MuiCollapse-wrapperInner">
<div>Child of hidden collapse</div>
</div>
</div>
</div>
Expected Behavior 🤔
Second element should render to:
<div class="MuiCollapse-container MuiCollapse-hidden" aria-hidden="true" style="min-height: 0px;">
<div class="MuiCollapse-wrapper">
<div class="MuiCollapse-wrapperInner">
<div>Child of hidden collapse</div>
</div>
</div>
</div>
Steps to Reproduce 🕹
https://codesandbox.io/s/still-tree-tmixq?file=/src/App.js
Steps:
- Open codesandbox
- Inspect the collapse parent, observe that there is no aria-hidden on the not rendered element
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
<Collapse /> does not apply aria-hidden="true" to not ... - GitHub
Steps: Open codesandbox; Inspect the collapse parent, observe that there is no aria-hidden on the not rendered element.
Read more >aria-expanded - Accessibility - MDN Web Docs - Mozilla
The aria-expanded attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not its child...
Read more >React.js: Component not rendering or showing up at all
When I inspect with the react dev tool the components aren't in the DOM at all. The html to follow has issues that...
Read more >Hiding DOM elements - ally.js
For disambiguation we'll use the following terms: Completely hidden: The element is not rendered on screen, not exposed in the accessibility tree, not...
Read more >content-visibility | CSS-Tricks
So when the rule is removed, the browser does not have to render the ... have aria-hidden="true" applied to them since the browser...
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
@karl-run Oh right. But only in JSDOM i.e. when using jest. In a browser they should not be included by
ByRole
. JSDOM doesn’t fully implement CSS cascade.Because if you have this:
Both buttons will be available in the tree when using
byRole
But with
aria-hidden="true"
:You are not able to look up the hidden element using
byRole
:Even when using
{ hidden: false }
both items are available.