fix(NcSelect): announce selected option to screen readers#8342
fix(NcSelect): announce selected option to screen readers#8342pringelmann wants to merge 3 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8342 +/- ##
==========================================
+ Coverage 52.37% 54.68% +2.31%
==========================================
Files 104 104
Lines 3393 3394 +1
Branches 989 990 +1
==========================================
+ Hits 1777 1856 +79
+ Misses 1360 1300 -60
+ Partials 256 238 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
susnux
left a comment
There was a problem hiding this comment.
Seems to work 👍
But I wonder if this should directly implemented in vue-select?
https://github.com/nextcloud-libraries/vue-select/
Good question: the aria-selected bug in |
Turns out this was already fixed in the fork, but seems we can't use that here since it still targets Vue 2 |
- Add aria-describedby to announce the selected value when the combobox receives focus - Inject a visually-hidden ", selected" marker into the option content so screen readers identify the selected option while browsing the dropdown Fixes #8322 Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
d2acefa to
e104429
Compare
| :name="String(option[localLabel])" | ||
| :search="search" /> | ||
| :search="search" | ||
| :aria-hidden="isOptionCurrentlySelected(option) || undefined" /> |
There was a problem hiding this comment.
Why not use native markup like aria-selected and role="option"?
There was a problem hiding this comment.
vue-select already puts role="option" and aria-selected on the <li> elements, but sets aria-selected based on keyboard focus position (typeAheadPointer) rather than actual selection - that's the root bug. The #option slot we use only controls the content inside each <li>, not the <li> attributes, so we can't override aria-selected from here without DOM manipulation that gets stomped on re-render.
This is already solved in our fork of vue-select, but we can't use that until it is migrated to Vue 3.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
This is already solved in our fork of vue-select, but we can't use that until it is migrated to Vue 3.
Ah wait too fast... 🙈
Then we should push forward the migration instead of tinker with our usage of it, as we will fail the other accessibility issues as well (those we fixed in the fork).
nextcloud-libraries/vue-select#25
There was a problem hiding this comment.
I will review effort required to bring it to completion
There was a problem hiding this comment.
Not quite a drop-in replacement, but is doable. Will revert the fix and switch to nextcloud/vue-select
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
☑️ Resolves
🖼️ Screenshots
N/A - behavioural fix, no visual change
🚧 Tasks
aria-describedbyon the search input pointing to a hidden span with the selected value. Screen readers announce it on focus.<item>, selectedmarker into the#optionslot for the currently selected option. Screen readers pick this up viaaria-activedescendantwhile navigating the list.🏁 Checklist
stable8for maintained Vue 2 version or not applicable