-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix: add aria-expanded to the toggler trigger #11052
Conversation
<a data-open="toggler">Open</a> | ||
<a data-close="toggler">Close</a> | ||
<a data-toggle="toggler">Toggle</a> | ||
</div>`).appendTo('body'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a generator here to avoid code duplication ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will prepare it then.
$('#toggler').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-close]').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open
, close
, open
. Should't it be toggle
?
Also, Cannot we use ('[data-open], [data-close], [data-toggle]')
here, or would this test for only the first element / one element and not every ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure here about toggler
. Will check it then.
$('#toggler').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-close]').should.have.attr('aria-expanded', 'true'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests. So let's tests only what the function should do alone and not all its side-effects. We tested that aria attribute are well set and updated above, no need to repeat it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
$('#toggler').should.have.attr('aria-expanded', 'false'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'false'); | ||
$triggers.find('[data-close]').should.have.attr('aria-expanded', 'false'); | ||
$triggers.find('[data-open]').should.have.attr('aria-expanded', 'false'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Pushed an update with the proposed changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM, thanks @DanielRuf !
The
aria-expanded
attribute should be on the trigger not the container of the toggled element(s).References:
https://www.w3.org/WAI/GL/wiki/Using_aria-expanded_to_indicate_the_state_of_a_collapsible_element
http://3needs.org/en/testing/code/aria-expanded.html
http://www.3needs.org/en/testing/code/aria-expanded-code.html
Closes #11049