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

Fixes accessibility issues with accordion #1176

Merged
merged 3 commits into from
Mar 8, 2017

Conversation

el-mapache
Copy link
Contributor

Why: previous implmentation wasn't using aria attributes correctly

**Why**: previous implmentation wasn't using aria attributes correctly
@monfresh
Copy link
Contributor

monfresh commented Mar 7, 2017

lgtm, but maybe @hursey013 should take a look too.

@monfresh monfresh requested a review from hursey013 March 7, 2017 15:41
Copy link
Member

@hursey013 hursey013 left a comment

Choose a reason for hiding this comment

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

In order to make the accordion keyboard accessible I think we'll want to have a tabindex="0" on the element that is acting as the button. We'll probably need to modify the JS a bit to allow a the keyboard to expand/collapse it as well because I think only a mouse click will work now.

@el-mapache
Copy link
Contributor Author

@hursey013 I added a keyup event binding. I'm going to need to refactor how this works a bit so we can remove the duplicated logic in previous-address.js and instead rely on the code already in the accordion component class

**Why**: WIA-ARIA Spec requires that an accordion component respond to
`enter` and `space` keys
@hursey013
Copy link
Member

@el-mapache Just tested it, works great! Final nitpick, would be nice to have tabindex=0 on the Close link at the bottom of the accordion so that is also keyboard accessible as well. Bonus points if upon closing the accordion the main header becomes focused again, since otherwise the focus will be lost inside the closed accordion.

Let me know if I can help with previous-address.js, I know that was sort of a temporary workaround on my part.

@el-mapache
Copy link
Contributor Author

@hursey013 So I don't know a lot about accessibility, is making the close link behave the same way just good practice? It seems like the close link is basically not needed in this case, since the user will remain focused on the heading element while the accordion is open.

This is probably very wrong wrt to how screen readers actually operate 😬

If the answer is just 'more is better' that makes sense to me too!

@hursey013
Copy link
Member

I'm definitely in the middle of learning more about accessibility, but one of the criteria we need to achieve is: "All functionality of the content is operable through a keyboard interface". So in the case of someone that cannot use a mouse, the expected behavior is that they will be able to tab to all links or interactive elements on the page, and each element will also have some sort of visual indication that it is currently in focus.

https://www.w3.org/TR/UNDERSTANDING-WCAG20/keyboard-operation.html https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-visible.html

@el-mapache
Copy link
Contributor Author

Yep, totally understand that some level of keyboard interaction is necessary for accessibility. Specifically, the page I was working off of (https://www.w3.org/TR/wai-aria-practices/#aria_ex) for this component specifies that only enter and space keys need to be handled for accessibility, any other keyboard commands are optional.

I guess my question is, do we ever stop and evaluate when to add things like a tabindex to secondary control elements or do we always just add it?

@hursey013
Copy link
Member

I think in this case since it appears visually to be a link it makes sense to have it behave like a link, but yeah I agree I don't think we should overdo it because that will actually have the opposite effect on accessibility. Sticking with semantic HTML will do most of the heavy lifting for us, I really just see us needing to pay extra attention to a few of our unique components like the accordions, modals and tooltips.

@el-mapache
Copy link
Contributor Author

That makes perfect sense, thanks!

@el-mapache el-mapache force-pushed the ab-accordion-accessibility branch 6 times, most recently from 0a2ffba to c1122fc Compare March 7, 2017 21:35
@el-mapache
Copy link
Contributor Author

@hursey013 seems like all the CC/rspec errors have been accounted for, if you wouldn't mind taking another look.

}

close() {
this.el.setAttribute('aria-expanded', 'false');
this.content.setAttribute('aria-hidden', 'true');
this.setExpanded(false);
Copy link
Member

Choose a reason for hiding this comment

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

Would it be ok if we add this.headerControl.focus(); within this close function so that if someone closes with the bottom close link, the focus outline gets reapplied to the header?

Like this:
screen recording 2017-03-07 at 04 52 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, forgot about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hursey013 focused!

**Why**: We were duplicating some logic in a file consuming the
accordion. Extra tabindicies mean extra accessibility
Copy link
Member

@hursey013 hursey013 left a comment

Choose a reason for hiding this comment

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

lgtm! thanks for cleaning up the previous address js as well!

@el-mapache el-mapache merged commit 1365664 into master Mar 8, 2017
@el-mapache el-mapache deleted the ab-accordion-accessibility branch March 8, 2017 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants