Problem/Motivation

Vertical tabs menu is not presented as navigation

Proposed resolution

Add a nav element to the vertical tabs.

Remaining tasks

TODO.

User interface changes

Improve document structure as conveyed to assistive tech.
No visual changes intended.

Original report by [username]

Spin-off from #2988431: [Meta] Accessibility plan for Media Library Widget. Comment #12.A.3 said "Vertical tabs menu is not presented as navigation".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Issue summary: View changes
Issue tags: -accessibility +Accessibility

Initially just separating this from #3035331: Improve keyboard focus behaviour of vertical tabs in MediaLibraryWidget. Will review later.

andrewmacpherson’s picture

Issue tags: -Accessibility +accessibility

Having a navigation landmark region inside a dialog sounds a bit strange to me, because we'd be dynamically changing the list of landmark regions when the dialog opens and closes. I'm going to ask about this one in the wider accessibility community.

I'm also not sure that a list of tabs amounts to navigation. In this case it's actually behaving more like an exposed filter for the view. Under the hood, it's a Views contextual filter, but the tabs have effectively put a UI on it. So it's more like we have our exposed filters in two different places in the dialog.

Whatever the case, our current Form API '#type' => 'vertical_tabs' does NOT have a navigation landmark. Instead the list is preceded by visually-hidden text saying they are vertical tabs.

There is an ARIA pattern for tabs, but we don't currently use it in Drupal core, but there's a note about it in #2893640: Modernize ARIA usage, in line with ARIA 1.1 and the ARIA Authoring Practices guide.. However the ARIA tabs pattern is a bit controversial - the main worry is that many users are not familiar with it, and some user studies have been published where sighted keyboard users were confused by them. So I don't want to rush into using those until they have broader consensus in the accessibility community.

Updated (2019-06-18): fixed a broken issue link in this comment.

seanB’s picture

Thanks for looking into this. I'll leave this for now. Very curious to see what the best way would be to improve this.

tim.plunkett’s picture

Issue tags: -accessibility (duplicate tag) +Accessibility

Fixing tag

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

@andrewmacpherson Does that mean we should close this issue?

mgifford’s picture

@andrewmacpherson & I talked about it. Let's leave this open. There is more that can be done, if only testing.

In looking for best practices, here are some related links:

Reasonably recent:
https://github.com/w3c/aria-practices/issues/459

Older articles:
http://simplyaccessible.com/article/danger-aria-tabs/
http://accessibleculture.org/articles/2010/08/aria-tabs/

phenaproxima’s picture

Sounds like we're waiting on a best practice to emerge from the W3C, so this is, essentially, postponed indefinitely.

However, that presents a bit of an issue from a release management standpoint. This issue is marked as a "must-have" child issue of #2988431: [Meta] Accessibility plan for Media Library Widget, which is itself a "must-have" child issue of #2834729: [META] Roadmap to stabilize Media Library. Which means, by extension, that Media Library cannot be marked stable until this issue is resolved.

So, we have a little problem here. We can't realistically block Media Library on the W3C, so we should probably re-prioritize this issue. We could either make it a "should-have" child of this issue, or remove it entirely from this issue and...get it to it when we get to it, regardless of Media Library's stability.

I won't change anything right now since it's not clear what the correct course of action is, but I'd like an accessibility expert to make the call on that. Then we can update this meta, and the release managers, accordingly.

mgifford’s picture

I think we can postpone this on https://github.com/w3c/aria-practices/issues/459

But @andrewmacpherson has dug into this more deeply that I have so would like it if he confirms this.

andrewmacpherson’s picture

Let's put aside the tabs pattern from the WAI-ARIA Authoring Practices for now. That's a red herring in this issue. In any case, our current Form API vertical tabs component doesn't use that pattern, and for the time being I'd like to avoid having two components that both look like vertical tabs behave in two different ways. (Eventually, I'd like to use the ARIA tabs pattern for both of these. Just not today.)

In #3, I said I'd ask around in the wider accessibility community, about whether a navigation landmark region made sense inside a dialog. I chatted with Scott O'Hara from Paciello Group, and described the dialog. We agreed that having landmarks inside of a dialog was serious overkill; if a dialog needs landmark regions, then you need to simplify the dialog. We noted that the media library is a rather complex dialog, but thought it would still be best to avoid using landmark regions inside a dialog. The main reason is that conceptually a dialog isn't really part of the page; in native desktop apps it's actually a separate window. However in web pages the screenreader landmarks tool will show all of the landmarks for the parent document. (That may improve in the future if/when the inert attribute gains support.)

For now, the problem that needs to be addressed is this part of comment #3:

I'm also not sure that a list of tabs amounts to navigation. In this case it's actually behaving more like an exposed filter for the view. Under the hood, it's a Views contextual filter, but the tabs have effectively put a UI on it. So it's more like we have our exposed filters in two different places in the dialog.

What needs to be conveyed is that these controls behave as a filter. The action is "click this control to show image media items".

Here's the markup we currently have from MediaLibraryUiBuilder::buildMediaTypeMenu():

<ul class="media-library-menu js-media-library-menu">
  <li class="media-library-menu-audio">
    <a href="/media-library?" class="media-library-menu__link active">
      Audio
      <span class="active-tab visually-hidden"> (active tab)</span>
    </a>
  </li>
  <li class="media-library-menu-document"> ... </li>
  <li class="media-library-menu-image"> ... </li>
  <li class="media-library-menu-remote-video"> ... </li>
  <li class="media-library-menu-video"> ... </li>
</ul>

Good parts:

  • There is a grouping element (the <ul>).
  • The currently-selected media type is indicated (the visually-hidden "active tab" text).

Bad parts:

  1. The behaviour semantics are misleading. The tabs are link elements, but they don't behave as hyperlinks for navigation.
  2. The purpose of the control is unclear. A link says "Document", but it isn't clear that pressing it will cause the dialog content to switch to listing document media entities.
  3. The visually-hidden "active tab" text is a bit misleading. I've witnessed screen reader users become confused when they hear the word tab, but the control doesn't behave like a ARIA tablist.
  4. Clicking the control causes content to change elsewhere in the dialog, but focus remains on the tab so it isn't clear that something has happened. The invisible "active tab" text goes some way to convey this, but I think it would benefit from a more explicit "something happened!" message.

TO FIX:

  1. Don't use links. Replace them with AJAX-enabled buttons.
  2. Include text which conveys the filter behaviour. The simplest idea may be something like <button type="button"><span class="visually-hidden">Show </span>Image<span class="visually-hidden"> media</span></button>. Take care to address WCAG SC 2.5.3 Label In Name. There should be no invisible text inside the visible label. It's okay to have visible text sandwiched between two hidden spans.
  3. Change the visually-hidden "(active tab)" to "(selected)", so it doesn't mislead screen reader users into thinking it behaves like an ARIA tablist.
  4. Use an AJAX AnnounceCommand to inform the user about what changed: "Showing Image media."
seanB’s picture

Attached is a first patch that implements the changes suggested in #11.

1. Instead of making the links real buttons, I've added role="button" to the links. If we want to change the link elements to actual button elements, we need to either:
- Make the menu a form with a submit button for each media type.
- Find a way to pass the URL we want to open to the button via a data attribute or something, so we can attach custom AJAX behavior via JS.
All options are not perfect and work around AJAX implementation limitations. For that reason, I chose to stick close to the current implementation.
2. Fixed.
3. Fixed.
4. Fixed. Added some explicit tests for it. Also added an extra test to make sure the links can be triggered using the spacebar now we added role="button".

seanB’s picture

Status: Active » Needs review
phenaproxima’s picture

+++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php
@@ -488,7 +488,22 @@ public function testWidget() {
+    $page->findLink('Type Three')->keyPress(32);

We should probably do something like $assert_session->elementExists('named', ['link', 'Type Three'])->keyPress(32) here, to avoid the possibility of calling a method on NULL.

Overall, the code looks good here; I think this patch will live and die on accessibility review, so tagging for that.

rainbreaw’s picture

@phenaproxima @seanB @andrewmacpherson - I tested this with VoiceOver on Mac OS X in Safari and Chrome, and the behavior is clear and understandable.

  1. I can quickly tab through the list and know exactly what they are, and understand them to be buttons,
  2. I know which is the currently active one because it reads "selected" to me
  3. I hear these to be buttons, and they behave as such in that I can use enter or spacebar to activate
  4. Once I select one, my focus is moved into the relevant group
  5. It is easy to get back to them with shift+tab

I personally consider this an accessible solution and would like to suggest that it is now reviewed and tested by the community.

seanB’s picture

Thanks @rainbreaw! Fixed #14 as well.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Welp, I’m happy with this if y’all is. RTBC once testbot confirms.

  • Gábor Hojtsy committed c793f99 on 8.8.x
    Issue #3035408 by seanB, andrewmacpherson, phenaproxima, mgifford,...
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Superb, thanks all.

  • Gábor Hojtsy committed 8eb888e on 8.7.x
    Issue #3035408 by seanB, andrewmacpherson, phenaproxima, mgifford,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.