Within my react application, I am noticing an issue in NVDA where my addition inside an aria-live
element is being read out multiple times. I only notice this issue within react, and cannot reproduce it in plain JavaScript.
I broke down my code into the smallest reproducible item. With NVDA 2018.1 in the Firefox 59.0.3, you can see NVDA reads out the change 6 times, one per variable.
https://codesandbox.io/s/lx8jykqprz
When you press go, the expected behavior is that it should read the new counters out once. However, it is read out 6 times. If you change around the number of ${this.state.counter}
variables, you will see the number of times it is read out is changed.
Has anyone else encountered this issue? If so, how did you work around it?
==============
Edit: As I stated in my comment under the accepted answer:
What I noticed is that in my example, react was rendering 6 text nodes, one for each counter variable. This, in combination with the aria-atomic
tag, was forcing the variables to be read multiple times.
By changing it to ${this.state.counter}${this.state.counter}${this.state.counter}${this.state.counter}${this.state.counter}${this.state.counter}
this fixed the issue as it rendered down to a single text node, and therefore the change was only read out once.