Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: Add "labelInAriaLive"-property for better accessibility #413

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

juhoValkonen
Copy link

What problem does this PR solve?

If the user moves between TreeSelect options using arrow keys, the screenreader will always read out the value of the active node. It would be much better for accessibility (and more flexible), if I as a developer could decide to use labels for aria-live content instead of the values.

What does the proposed API look like?

New prop would be labelInAriaLive, and it would be false by default. This prop would then be used to decide whether to use the value or label of the selected item, when rendering the aria-live tag of the component.

Using the component with the implemented feature:

<TreeSelect
        labelInAriaLive={true} // This is the new prop
        treeDefaultExpandAll
        treeData={[{ value: 'parent', label: 'parent-label', children: [{ value: 'child', label: 'child-label' }] }]}
        multiple
      />

Juho Valkonen added 3 commits May 24, 2022 13:34
Aria-live of TreeSelect option was always updated with the value of the option.
In some cases there is some sort of ID in the value field (not relevant for user),
and the textual representation in label. In those cases, users
with screenreaders are confused, as they hear only some ID-numbers instead
of option labels. This is a huge problem for accessibility.
Solution
Allow developer to decide whether to use option label in aria-live area.
There is a new prop ´bool labelInAriaLive (default=false)´ , that
the developer can use if he/she wishes. This is a huge enabler for
improving accessibility.
Notes
Also testcase was added and documentation was updated in this commit.

This commit will not break any existing usage of treeSelect component,
as the default for new prop is false. If ´labelInAriaLive´ is false,
everything will work as expected.
Aria-live of TreeSelect option was always updated with the value of the option.
In some cases there is some sort of ID in the value field (not relevant for user),
and the textual representation in label. In those cases, users
with screenreaders are confused, as they hear only some ID-numbers instead
of option labels. This is a huge problem for accessibility.

Solution

Allow developer to decide whether to use option label in aria-live area.
There is a new prop ´bool labelInAriaLive (default=false)´ , that
the developer can use if he/she wishes. This is a huge enabler for
improving accessibility.

Notes

Also testcase was added and documentation was updated in this commit.
This commit will not break any existing usage of treeSelect component,
as the default for new prop is false. If ´labelInAriaLive´ is false,
everything will work as expected.
@vercel
Copy link

vercel bot commented May 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
tree-select ✅ Ready (Inspect) Visit Preview Jul 29, 2022 at 5:37AM (UTC)

@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #413 (92136b5) into master (50509e7) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 92136b5 differs from pull request most recent head 82028b3. Consider uploading reports for the commit 82028b3 to get more accurate results

@@            Coverage Diff            @@
##            master      #413   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines          468       469    +1     
  Branches       133       136    +3     
=========================================
+ Hits           468       469    +1     
Impacted Files Coverage Δ
src/TreeSelect.tsx 100.00% <ø> (ø)
src/TreeSelectContext.ts 100.00% <ø> (ø)
src/OptionList.tsx 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@juhoValkonen
Copy link
Author

Hi @zombieJ : Any idea when this feature would be merged and released?

@Szeretni
Copy link

This is very useful because some times the value is, for example, a hash or similar identifier, which isn't meaningful to the end user. Any issues with this improvement @zombieJ ?

@yoyo837
Copy link
Member

yoyo837 commented Dec 26, 2023

Conflict!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants