Skip to content

Critical accessibility issues: aria roles and aria-label #3355

Closed
baophucct/codesandboxer
#1

Description

@geoffrich

When running the Axe accessibility tester against the react-select v2 code-sandbox, two critical issues are identified:

  • Form elements must have labels. While you can pass aria-label as a prop to the Select component, it is not assigned as an attribute to the #react-select-2-input HTML element. Adding this attribute satisfies the Axe tester.
  • Certain ARIA roles must be contained by particular parents. Each .select__option has role="option"; however, the parent div .select__menu-list does not have role="listbox". Adding this attribute satisfies the Axe tester. Note that I had to use React Developer Tools to set menuIsOpen on the StateManager to see this violation.

Below are screenshots of the Axe test results.
Form elements must have labels

Certain ARIA roles must be contained by particular parents

Activity

  1. gwyneplaine commented on Jan 16, 2019

    @gwyneplaine
    Collaborator

    thanks for this @geoffrey1218, we'll have a closer look at these to harden accessibility in selects.
    If you have the time and thoughts on how to do so, PRs are warmly welcome.

  2. gwyneplaine commented on Feb 4, 2019

    @gwyneplaine
    Collaborator

    @sarahbethfederman if you could have a look at this issue, that would be awesome

  3. sarahbethfederman commented on Feb 4, 2019

    @sarahbethfederman
    Collaborator

    Hi! I'm not able to reproduce the first issue. May be that it was fixed in react-autosize-input. When providing an aria-label prop to the Select, it seems to be applied to the input. Here's a sandbox demo-ing this with a label value of "this is a label!!!" https://ryw61w7rnn.codesandbox.io/
    Running axe on this sandbox produces no valid issues.

    Looking into second issue now :)

  4. sarahbethfederman commented on Feb 25, 2019

    @sarahbethfederman
    Collaborator

    I think this issue can be closed

  5. sarahbethfederman commented on Feb 25, 2019

    @sarahbethfederman
    Collaborator

    (someone yell at me if I'm not supposed to close issues)

  6. bmsuseluda commented on Jun 7, 2019

    @bmsuseluda

    doesn't work for me if isSearchable is false. Can you check the reason behind this?

  7. sarahbethfederman commented on Jun 8, 2019

    @sarahbethfederman
    Collaborator

    @bmsuseluda can you be a bit more specific about what part isn't working for you? Happy to look into this.

  8. bmsuseluda commented on Jun 11, 2019

    @bmsuseluda

    Sorry for my short message.
    I'm using the following code:
    <ReactSelect className={styles.dropdown} options={options} value={value} defaultValue={defaultValue} isLoading={isLoading} isDisabled={isDisabled} onChange={handleOnChange} placeholder={placeholder} components={{ DropdownIndicator, Menu }} isSearchable={false} ariaLabel={label} />
    My problem is that the aria-label will not be set on the input element if isSearchable is false.

  9. IanLunn commented on Jul 4, 2019

    @IanLunn

    Issue should be reopened. aria-label isn't applied if isSearchable is set to false.

    The input reported by Axe is <input id="react-select-2-input" readonly="" tabindex="0" class="css-gj7qu5-dummyInput" value="">

    @bmsuseluda You should actually be using hyphen cased syntax for aria attributes but that is not the issue here -- aria-label doesn't work either.

  10. ZLJasonG commented on Aug 22, 2019

    @ZLJasonG

    Can confirm this is still broken in 3.0.4

  11. ZLJasonG commented on Aug 23, 2019

    @ZLJasonG

    Looks like the issue is in Select.js renderInput, if !isSearchable it renders a DummyInput without applying the aria attributes that it does to the normal Input it renders otherwise.

  12. nice-rain commented on Aug 26, 2019

    @nice-rain

    @ZLJasonG I am having this exact same issue too. If when isSearchable is false, it will not pass through the aria label.

  13. lauracabre commented on Jan 21, 2020

    @lauracabre

    I am also having this issue. @sarahbethfederman could this issue be reopened?

  14. 8 remaining items

  15. added
    issue/has-prIssue has a PR attached to it that may solve the issue
    on Jul 6, 2020
  16. kschwarz1116 commented on Jul 20, 2020

    @kschwarz1116

    I'm still encountering this on 3.1. isSearchable doesn't appear to be the only cause, but I'm still investigating on that front.
    @bladey & @snyk-bot, it looks like the linked PR doesn't actually fix this, it was only referencing #3407 which was why this issue got closed and then re-opened before.

  17. removed
    issue/has-prIssue has a PR attached to it that may solve the issue
    on Jul 21, 2020
  18. added
    issue/reviewedIssue has recently been reviewed (mid-2020)
    and removed
    issue/reviewedIssue has recently been reviewed (mid-2020)
    on Aug 24, 2020
  19. onebree commented on Nov 11, 2020

    @onebree

    Applying aria-label simply to the <input /> isn't enough. Just upgraded to v3, excited by the aria-label inclusion. However, that's the only place it gets applied. There's no other aria properties to set for say, the X to remove a multi-select option.

    I am using React Testing Library, which locates elements like a user would (text, labels, aria-label or aria-role), and because this X is actually an SVG, I'm not sure how to immediately select it (without breaking RTL conventions)

  20. kylemh commented on Nov 11, 2020

    @kylemh

    Your point is still valid, @onebree, but just in case this helps ya: https://github.com/romgain/react-select-event

  21. onebree commented on Nov 11, 2020

    @onebree

    @kylemh Thanks! I'll definitely consider adding that to the project. In the meantime, I was able to call container via RTL, and querySelector from there

  22. Methuselah96 commented on Nov 14, 2020

    @Methuselah96
    Collaborator

    I've started a fork of react-select. Feel free to resubmit this issue on the fork and/or submit a PR to resolve this issue on the fork and we can get it merged and released.

    EDIT: 🎉 I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance!

  23. ebonow commented on Jan 18, 2021

    @ebonow
    Collaborator

    Greetings,

    This issue was reopened due to the use-case of the aria-label not being applied to the "DummyInput" which impairs accessibility to the Select when isSearchable = false.

    I can confirm that this behavior has been addressed here: #3090
    demo: codesandbox
    Screen Shot 2021-01-18 at 11 48 43 AM

    Since the described behavior which caused this issue to be reopened has been resolved, I will be closing this issue again with the understanding that this will give more visibility to remaining accessibility issues.

  24. marisev commented on Apr 27, 2021

    @marisev

    Hi @geoffrich ! In your initial question you referenced react-select v2 code-sandbox, and I see that all options in this example have role="option". Any chance you could share what was the trick to get the role="option" applied in the example?

    The only way I see from the docs is by customizing Option, like this: <components.Option role="option" ... />. But it doesn't really work. I am curious how it was implemented in your example. Thanks in advance!

  25. ebonow commented on Apr 27, 2021

    @ebonow
    Collaborator

    Greetings @marisev,

    Attributes can be applied to a custom component by accessing the the innerProps.

    I posted an implementation method here specifically for accessibility that might be of interest. #4322 (comment)

    Please let me know if you have any questions.

  26. marisev commented on Apr 27, 2021

    @marisev

    @ebonow Thank you Eric, I just tried using innerProps and it works! Really appreciate your help, you saved my day!
    PS: now I see information about innerProps in the docs, it just wasn't obvious how/when to use it. But it makes sense now.

  27. ebonow commented on Apr 27, 2021

    @ebonow
    Collaborator

    @marisev glad it's working for you Marina! No worries as the documentation is admittedly a bit dense and easy to miss things. It's in the process of being completely redesigned so it should be a bit easier to sift through everything in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/accessibilityIssues or PRs related to accessibilityissue/reviewedIssue has recently been reviewed (mid-2020)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions