I have a simple accordion:
<div>
<button aria-expanded='false' aria-controls='content'>
Open accordion
</button>
<div id='content' aria-hidden='true'>
This the accordion's hidden content.
</div>
</div>
I use Javascript to open/close the accordion and set the aria-* tags.
Everything works fine but when I add links inside the content:
<div>
<button aria-expanded='false' aria-controls='content'>
Open accordion
</button>
<div id='content' aria-hidden='true'>
This is the accordion's hidden content.
<a href='https://www.google.com'>Go to Google</a>
</div>
</div>
Lighthouse gives me this:
[aria-hidden="true"] elements contain focusable descendents
It seems to me that adding tabindex='-1' to the a tag solves the issue:
<a tabindex='-1' href='https://www.google.com'>Go to Google</a>
However, that makes the element "non-tabbable", which is not good for accessibility.
I could use JavaScript to manually query for all a tags inside an accordion's content but I am not even sure if this really solves the "issue" or is a dirty work-around? Are there any better alternatives?