Skip to content

Add some aria attribute to dropdown for accessibility purposes#469

Open
Leusev wants to merge 2 commits intozurb:masterfrom
Leusev:feat/add_aria_attributes
Open

Add some aria attribute to dropdown for accessibility purposes#469
Leusev wants to merge 2 commits intozurb:masterfrom
Leusev:feat/add_aria_attributes

Conversation

@Leusev
Copy link
Copy Markdown

@Leusev Leusev commented May 15, 2020

Purpose

While working on a side projecte that uses Tribute.js to implement an user's dropdown list to add into a list, I was asked to add some aria's accessibility functionality to input and its dropdown list.
I realised I was unable to link the dropdown <ul element to the input with an "aria-owns" attribute because <ul element lacks of ii, as well as the <li element neither had 'role="option"'

Accessibility functions

As an example, I was following some aria best practices like these:

📷 Screenshots

Now:

image

With aria attributes:

image

@Leusev
Copy link
Copy Markdown
Author

Leusev commented Jun 3, 2020

Hello @mrsweaters
when you have a moment, could you take a look at this PR please?
Thanks in advance
Greetings

src/Tribute.js Outdated
ul = this.range.getDocument().createElement("ul");
wrapper.className = containerClass;
wrapper.setAttribute('aria-expanded','true');
ul.setAttribute('id','results');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be more specific to tribute? Maybe tributeResults.

Copy link
Copy Markdown
Author

@Leusev Leusev Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Change done @mrsweaters !
Thanks

@Leusev
Copy link
Copy Markdown
Author

Leusev commented Jun 30, 2020

Good morning @mrsweaters
when you can if you can review the changes you asked me please.. :)
Thanks in advance!

ul = this.range.getDocument().createElement("ul");
wrapper.className = containerClass;
wrapper.setAttribute('aria-expanded','true');
ul.setAttribute('id','tributeResults');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will cause issues when multiple instance of tribute are used in the page, because it will create duplicate ids. The uniqueness of ids must be preserved.

A solution could be to use el.id + '-tributeResults' (and maybe skip the id entirely if el does not have an id, as generating a random part for the id won't be useful to reference it from the outside). This way, the id stays unique (assuming that the page was not using duplicate ids and that it was not already using a -tributeResults suffix in its set of ids of course) while being deterministic and user-controlled (making it possible to reference the id in aria attributes maintained outside tribute).

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants