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

Dropdown: accessibility problem (screen readers) #1834

Closed
Sole-Valero opened this issue Jul 5, 2017 · 11 comments
Closed

Dropdown: accessibility problem (screen readers) #1834

Sole-Valero opened this issue Jul 5, 2017 · 11 comments
Labels

Comments

@Sole-Valero
Copy link
Contributor

Sole-Valero commented Jul 5, 2017

Description

If you use Dropdown passing the items using options, it is keyboard accessible but with a screen reader the options are not read aloud as you move through them.

Steps

Reach a dropdowns with keyboard, and uses arrows keys to move through options

Expected Result

When you move through options, options are read aloud

Actual Result

Options are not read aloud

Version

0.70.0

Testcase

e.g. https://react.semantic-ui.com/modules/dropdown#dropdown-example-inline

Contribution

I can contribute patching it modifying the Semantic-UI-React/src/modules/Dropdown/Dropdown.js, in function renderText = () => (line 1028),
adding the following aria labels to the redered div (when className='text'):
role='alert' aria-live='polite'

@layershifter
Copy link
Member

@Sole-Valero PRs are welcome, will be glad to see your contributions 👍

@layershifter layershifter changed the title Dropdown accessibility problem (screen readers) - bug Dropdown: accessibility problem (screen readers) Jul 5, 2017
@layershifter
Copy link
Member

layershifter commented Jul 5, 2017

Also please write why proposed behavior is correct, I'm not familiar with aria attributes

@Sole-Valero
Copy link
Contributor Author

Sole-Valero commented Jul 5, 2017

I'm on it (PR)

@Sole-Valero
Copy link
Contributor Author

Sole-Valero commented Jul 5, 2017

In the Dropdown element, you use a div area to display the text corresponding to the selected item. If you don't use role='alert', screen readers don't notice when the text changes, so it doesn't read it again to the users...and users don't know which option is selected...

@Sole-Valero
Copy link
Contributor Author

An interesting article about accessibility and react:
https://facebook.github.io/react/docs/accessibility.html

@layershifter
Copy link
Member

@Sole-Valero Thanks for clarification 👍

@Sole-Valero
Copy link
Contributor Author

Sole-Valero commented Jul 5, 2017

@layershifter I can't check my changes...I run $npm run docs , but it gives me :

[12:46:29] Starting 'serve:docs'... [12:46:29] 'serve:docs' errored after 101 ms [12:46:29] Error: listen EADDRINUSE 127.0.0.1:8080 at Object.exports._errnoException (util.js:1026:11) at exports._exceptionWithHostPort (util.js:1049:20) at Server.setupListenHandle [as _listen2] (net.js:1305:14) at listenInCluster (net.js:1353:12) at doListen (net.js:1479:7) at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:84:16) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:100:10) [12:46:29] 'docs' errored after 35 s

My node version is v8.0.0
My npm version is 5.04
It seems an error creating the port to listen....no?

@layershifter
Copy link
Member

Seems that something has already listening your 8080 port.

Sole-Valero added a commit to Sole-Valero/Semantic-UI-React that referenced this issue Jul 5, 2017
Sole-Valero added a commit to Sole-Valero/Semantic-UI-React that referenced this issue Jul 7, 2017
)

		- Dropdown.js --> coded added now is more simple.
Sole-Valero added a commit to Sole-Valero/Semantic-UI-React that referenced this issue Jul 7, 2017
Sole-Valero added a commit to Sole-Valero/Semantic-UI-React that referenced this issue Jul 12, 2017
        - Dropdown.js->renderTex--> now always returns the text rendered with aria labels: role='alert' aria-live='polite'
levithomason pushed a commit that referenced this issue Jul 16, 2017
* fix(Dropdown): accessibility problem (screen readers)(#1834)

*  fix(Dropdown): accessibility problem (screen readers)(#1834)
		- Dropdown.js --> coded added now is more simple.

* fix(Dropdown): accessibility problem (screen readers)(#1834)
	- patched an error. Forgotten '}'

* fix(Dropdown): accessibility problem (screen readers)(#1834)
        - Dropdown.js->renderTex--> now always returns the text rendered with aria labels: role='alert' aria-live='polite'

* fix lint issue
@devarshipant
Copy link

devarshipant commented Mar 8, 2018

@Sole-Valero -- we have a similar implementation with aria-live polite and role alert using 'semantic react,' but both screen readers (JAWS 18 and NVDA 2017) fail to speak the selected list item (see attached). Screen reader will only speak the label 'Search for cases by' because of the aria-labelledby reference, but not the selected item (Name, as shown in the screenshot).

Do you have any suggestions to make the widget accessible?

I am not sure using aria-live = polite and role = alert is an effective solution here.

A few things might fix it:

  1. Use label with for attribute.

  2. Use input with appropriate type attribute with a matching ID.

  3. Appropriate styles.

If ARIA must be used and the look and feel needs to be preserved, we can do the following:

  1. Use aria-active-descendant and update its value to the ID of the focused listbox item.

  2. Use button element with aria-haspopup = listbox.

  3. Use tabindex = -1 on the UL to allow arrow key navigation and register events onkeydown.

See a working example at https://codepen.io/devpant/pen/wpVPpL that works with screen readers.

aria-live--role-alert

@jutunen
Copy link

jutunen commented Mar 31, 2022

Why has this issue been closed? This is still a valid issue, I have written a Gist about it: https://gist.github.com/jutunen/d8c3948656f449cdb1da8addaac0c766

@gutumd
Copy link

gutumd commented Dec 12, 2023

Hello there, Semantic UI Dropdown component still don't have aria-label and input component that is used for entering search query is not readed by screen reader, I have fixed it with this tricky implementation:
(Set a placeholder programmatically and give it transparent color from styles)
https://codesandbox.io/p/sandbox/semantic-ui-example-forked-2mvnx6?file=%2Fexample.js%3A38%2C24

image

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

No branches or pull requests

5 participants