Skip to content

Improve accessibility for dashboard course settings dropdown - #11393

Merged
clytwynec merged 2 commits into
masterfrom
clytwynec/ac-238
Mar 10, 2016
Merged

Improve accessibility for dashboard course settings dropdown#11393
clytwynec merged 2 commits into
masterfrom
clytwynec/ac-238

Conversation

@clytwynec

Copy link
Copy Markdown
Contributor

Overview

There was an a11y test failure for the course setting dropdowns on the dashboard page (see AC-238).

  • After looking closer, the reason the test fails is because the DIV is hidden at the time the test runs. It is only shown (and made focusable) after the link it clicked. Because this isn't an issue with the actual implementation, and instead and issue with the timing of the test, I've updated the test to explicitly ignore this element for the audit, rather than ignoring the entire rule. Once AC-179 is done, the link-href rule should be enabled to ensure that skip-links on these pages work.
  • The link has been updated to be a button, and focus in the dropdown is now managed. Focus is trapped in the dropdown when it opens and navigable via ARROW and TAB keys. Pressing ESC or SPACE or clicking the button again will close the dropdown and return focus to the button. Because this required a decent update the functionality in legacy.js (which is not intended to be developed further), I moved the Javascript to it's own module and added tests.
  • The originally failing a11y tests now pass.
  • There was another usability issue with this dropdown that is addressed in this PR. If multiple courses are on a page, there would be several links that say "Course options dropdown". I've updated that text to include the course name as well.

Sandbox

https://clytwynec-ac-238.sandbox.edx.org/

Reviewers

@clrux @cptvitamin

@downzer0

downzer0 commented Feb 1, 2016

Copy link
Copy Markdown
Contributor

Nice sleuthing, @clytwynec.

I do have one request though: could you add either a colon (":") or the word "for" after "Course options dropdown"? Even with the improved context, the lack of a pause makes it difficult to really differentiate. It could just be my inexperienced ears (maybe folks who are proficient with screen readers and use them regularly wouldn't have the issue) but a bit of a pause would be nice. However, let's see what @cptvitamin thinks first.

Otherwise, nice work 👍

@cptvitamin

Copy link
Copy Markdown
Contributor

I agree with Chris here, but prefer a different approach. I don't want to explicitly say "dropdown" since the ARIA already reveals that this control has a popup and its current state. Instead of a pause, lets just have the link text read "Course options for [name of course]" that way no pause is needed, each link is unique, and we don't redundantly describe the type of control.

Now that we have the value of the text out of the way, wouldn't this test failure go away if this were a button? I find it odd that we are using a link with an href value of a page fragment (that isn't a heading and isn't focusable) It probably seemed like a good idea to the dev at the time, but I think using a button with JS on it would be better. add a tabindex=-1 on the div and move focus to that upon activation. I also noticed that you can tab past this menu and leave it open. We should probably have it close on blur.

Thoughts?

@clytwynec
clytwynec force-pushed the clytwynec/ac-238 branch 2 times, most recently from 8c43956 to 50e697d Compare February 16, 2016 20:36
@clytwynec

Copy link
Copy Markdown
Contributor Author

@clrux @cptvitamin Please resume review. I've updated the description to reflect the changes and included a sandbox.

<div class="wrapper-action-more" data-course-key="course-v1:DelftX+CTB3365DWx+1T2016">
<a href="#actions-dropdown-2" class="action action-more" id="actions-dropdown-link-2" aria-haspopup="true" aria-expanded="false" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="2">
<span class="sr">Course options dropdown</span>
<button type='button'class="action action-more" id="actions-dropdown-link-1" aria-haspopup="true" aria-expanded="false" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="1">

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.

we should add aria-controls attribute here that references the actions-dropdown-# div?

<div class="wrapper-action-more" data-course-key="${enrollment.course_id}">
<a href="#actions-dropdown-${dashboard_index}" class="action action-more" id="actions-dropdown-link-${dashboard_index}" aria-haspopup="true" aria-expanded="false" data-course-number="${course_overview.number | h}" data-course-name="${course_overview.display_name_with_default_escaped | h}" data-dashboard-index="${dashboard_index}">
<span class="sr">${_('Course options dropdown')}</span>
<button type="button" class="action action-more" id="actions-dropdown-link-${dashboard_index}" aria-haspopup="true" aria-expanded="false" aria-controls="actions-dropdown-${dashboard_index}" data-course-number="${course_overview.number | h}" data-course-name="${course_overview.display_name_with_default_escaped | h}" data-dashboard-index="${dashboard_index}">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cptvitamin I've updated his to include an aria-controls attribute.

@cptvitamin

Copy link
Copy Markdown
Contributor

This tested great with a screen reader and keyboard. Nice work. The removal of that aria-label on the parent container fixed that issue we were seeing in VO.

👍

@clytwynec clytwynec changed the title Improve screenreader text for dashboard course settings dropdown Improve accessibility for dashboard course settings dropdown Mar 2, 2016
@cahrens

cahrens commented Mar 2, 2016

Copy link
Copy Markdown

@andy-armstrong Thanks for reviewing this PR.

@andy-armstrong

Copy link
Copy Markdown
Contributor

@clytwynec Before reviewing this, I was wondering if you'd considered using the dropdown that @AlasdairSwan wrote for Drupal that he also introduced into the UI Toolkit. The plan was for this to be used in the platform as soon as we complete the FedX upgrades to support the toolkit (mostly upgrading old JS libraries).

My preference would be to take what you've learned here and apply it (if necessary) to Alasdair's work in the UI Toolkit. We'll then prioritize switching the dropdown over as soon as the platform is using the UI Toolkit.

FYI, here's Alasdair's implementation:

https://github.com/edx/edx-ui-toolkit/tree/master/src/js/dropdown-menu

@clytwynec

Copy link
Copy Markdown
Contributor Author

@andy-armstrong What is the timeline for the UI Toolkit in platform? Is that the same dropdown currently implemented on the home page (top right corner when logged in)?

@AlasdairSwan

Copy link
Copy Markdown
Contributor

@clytwynec it is the same dropdown as implemented on the marketing site top right corner.

@andy-armstrong

Copy link
Copy Markdown
Contributor

@clytwynec We are about two to three sprints away from landing the UI Toolkit in platform, so hopefully early April. The big challenge is in upgrading all the JavaScript libraries which are unbelievably outdated (over three years old, in some cases).

@clytwynec

Copy link
Copy Markdown
Contributor Author

@andy-armstrong @AlasdairSwan I'm happy to go with the implementation in the UI toolkit when it gets implemented in the platform. I can take a look at that implementation to see if there are any fixes in this PR that should be addressed there. Happy to make a PR if to the toolkit if needed, or open a JIRA ticket if that seems more appropriate to you.

Does that seem ok with you @cptvitamin? There are other changes in this PR that will still need to get pushed through (e.g. a --> button, and proper labeling of said button), but I could hold off on the javascript changes.

@cptvitamin

Copy link
Copy Markdown
Contributor

@andy-armstrong is there any harm in having @clytwynec merge her changes now (the work is already done) and then having her apply what she learned and improved here to the UI Toolkit? Once the Toolkit is in platform it should be relatively easy to switch this control to use the pattern. I just don't see the point of holding this work up if it's already complete (and a cursory review results in no obvious red flags).

@andy-armstrong

Copy link
Copy Markdown
Contributor

@cptvitamin Merging it as is makes sense to me. My original point was just that the UI Toolkit version exists and I wondered if it had been considered.

@clytwynec Nice work! 👍

One minor concern is that we're having difficulty with focus-related Jasmine tests as we upgrade to the new version of JQuery. We may find that they become flaky and will have to be removed. FYI @cahrens.

@clytwynec

Copy link
Copy Markdown
Contributor Author

@andy-armstrong Thanks for taking a look. I'll take another look at the toolkit version too and make sure anything here that may need to be updated gets updated (see AC-361).

verifyDropdownNotVisible = function() {
expect($(dropdownSelector)).not.toBeVisible();
},
waitForElementToBeFocused = function(element, desc) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andy-armstrong @cahrens Are the JS tests related to focus that are flaky using any sort of waitsFor method like this? I know when I tried to use the expect().toBeFocused method, it was flaky.

clytwynec pushed a commit that referenced this pull request Mar 10, 2016
Improve accessibility for dashboard course settings dropdown
@clytwynec
clytwynec merged commit 5b5b4eb into master Mar 10, 2016
@clytwynec
clytwynec deleted the clytwynec/ac-238 branch March 10, 2016 17:30
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 this pull request may close these issues.

6 participants