I have to make screen readers announce the fact that a section is displayed. This section is displayed based on a boolean value that is changed when the user clicks on a link.
This is how it is implemented so far:
import { Row } from 'react-bootstrap';
...
const [shouldDisplay, setShouldDisplay] = useState<boolean>(false);
...
return(
{!shouldDisplay && (
<a href="somepage.com" onClick={setShouldDisplay(true)} />
)}
{shouldDisplay && (
<Row>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</Row>)}
);
I have tried to add aria-live="polite" to the Row but the screen readers still don’t announce the fact that the new part with the lorem ipsum is displayed. It should announce "Lorem ipsum part is displayed" or at least "expanded" like the case when Collapse from react-bootstrap, with aria-expanded="true" is used. Is there a way to achieve this?
2
Answers
I think you are on the right track with
aria-live
:https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#live_regions
Ideas:
try wrapping the Row in a div with aria label.
Row is a functional component, and you cannot apply DOM attributes directly to it if it doesn’t accept those attributes as props.