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

Accessibility: aria-owns is set to a class rather than an id #191

Closed
ariross opened this issue May 29, 2020 · 2 comments · Fixed by #193
Closed

Accessibility: aria-owns is set to a class rather than an id #191

ariross opened this issue May 29, 2020 · 2 comments · Fixed by #193

Comments

@ariross
Copy link

ariross commented May 29, 2020

  • vue-autosuggest version: 2.0.2
  • node version: v10.15.2
  • npm (or yarn) version: 6.4.1

Relevant code or config

<div id="autosuggest">
    <input type="text" aria-owns="autosuggest__results" {...blahBlahProps} id="autosuggest__input" placeholder="Type 'e'" class="autosuggest__input--open"> 
    <div class="autosuggest__results-container">
        <div aria-labelledby="autosuggest" class="autosuggest__results">...</div>
     </div>
</div>

What you did:

  1. Go to https://darrenjennings.github.io/vue-autosuggest/
  2. Type something in autocomplete search so that you get suggestions
  3. Run an accessibility tool (like aXe) or just observe aria-owns attribute on input field

What happened:

A violation concerning aria-owns is captured.

image

Reproduction sandbox/repository:
https://darrenjennings.github.io/vue-autosuggest/

Problem description:

aria-owns is set to autosuggest__results, which is a class rather than an id. aria-owns only accepts ids.

Suggested solution:

Add an id to the autosuggest__results-container element (not autosuggest__results since it is conditionally rendered, and aria-owns must be given an id of an element that exists). Ideally, this would be based off of the main element's id. That way, custom ids can be created so that multiple autosuggests can live on the same page.

something like:

<div id="autosuggest-CUSTOM-ID">
    <input type="text" aria-owns="autosuggest-CUSTOM-ID__results-container" {...blahBlahProps} id="autosuggest__input" placeholder="Type 'e'" class="autosuggest__input--open"> 
    <div class="autosuggest__results-container" id="autosuggest-CUSTOM-ID__results-container">
        <div aria-labelledby="autosuggest" class="autosuggest__results">...</div>
     </div>
</div>
@darrenjennings
Copy link
Owner

thanks for the note. I was not aware of axe so will check it out and get this fixed!

@darrenjennings
Copy link
Owner

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 a pull request may close this issue.

2 participants