I have a site that needs to be made fully accessible. We have dynamic content that sits on a single page (doesn't reload) and changes on the screen.
For the screen-reader to keep up with this, I've added some JS logic where the attribute aria-hidden="true" or aria-live= "polite" is added to hide and reveal the targeted elements.
Although the element's aria-label is read out, I run into an issue where the role attribute is left out.
Situation 1
<div role="button" aria-label="This is a label" aria-hidden="true"></div>
I use JS to remove the attribute aria-hidden and add aria-live="polite" when this button needs to be read on the page
Which makes the screen-reader then read "This is a label"
Situation 2
<div role="button" aria-label="This is a label"></div>
However, if the content is read from the get-go without being hidden, i.e. no aria-hidden="true" it reads as "This is a label, Button"
I want this behaviour, but with me able to control when this occurs.
I'm using iOS screen reader on the latest Chrome.
I've tried quite a few hacks to get around this:
- Setting
aria-hidden="true"to parent and indivdual elements results in role still being omitted - Not using
aria-live="polite"to reveal but the oppositearia-hidden="false". This however won't even get picked up by the screen-reader
Any help or guidance much appreciated.
Additional JSFiddle, with a simplified example (you can use Apple screenreader and click into the window to hear the content read):