I am currently using select2.js version 4.0 and having this issue where screen reader (NVDA) won't read the selected option, even aria-selected="true" is added correctly to the current selected li. And when I go the unselected options, it read as example, "German not selected" which is correct. I tried using the version 4.1 as well but still having the same problem. I was wondering if there's an issue with aria-selected="true" in select2.js? can't really find a stated issue for this. Thanks for the help.
Here's my select option after select2 is applied,

And here's the view when opened

That's how NVDA works. Each screen reader (NVDA, JAWS, Voiceover, Talkback, Narrator, etc) will choose how to announce aria attributes. In this case, for aria-selected, you get different results for aria-selected depending on the role of the element and you get different results in different browsers. You can try to code around this by having your own hidden text that the screen reader reads but in general it's just best to let the screen reader decide how an attribute will be read.
Here's how convoluted aria-selected is just for Firefox and Chrome (let alone Edge, Safari, or IE). And this is just with NVDA. I'm sure the results will be difference for JAWS, Voiceover, etc.
role="tab"
aria-selected attribute or notaria-selected=falserole="option"
aria-selected attribute or notaria-selected=truerole="gridcell"
aria-selected attribute or notaria-selected=truerole="row" (same behavior as option)
aria-selected attribute or notaria-selected=truerole="tab" (different than firefox)
aria-selected attribute or notaria-selected=truerole="option" (same behavior as firefox)
aria-selected attribute or notaria-selected=truerole="gridcell" (different than firefox)
role="row" (different than firefox)
aria-selected attribute or notaria-selected=falseIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With