Currently, menu item containers are just wrapped in a <span class="menu-item-container">.

But, these items are not as accessible as regular links. Most browsers have facilities for keyboard navigation to all links. Which leaves these containers out in the cold.

I did some research into tabindex and discovered an obscure reference in the W3C spec. http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex

Elements that may receive focus should be navigated by user agents according to the following rules:

  1. Those elements that support the tabindex attribute and assign a positive value to it are navigated first. Navigation proceeds from the element with the lowest tabindex value to the element with the highest value. Values need not be sequential nor must they begin with any particular value. Elements that have identical tabindex values should be navigated in the order they appear in the character stream.
  2. Those elements that do not support the tabindex attribute or support it and assign it a value of "0" are navigated next. These elements are navigated in the order they appear in the character stream.
  3. Elements that are disabled do not participate in the tabbing order.

(Emphasis mine)

A quick Google search proved adding tabindex=0 to the container's span should work as expected. See http://snook.ca/archives/accessibility_and_usability/elements_focusable_...

CommentFileSizeAuthor
#4 1032546-3-tabindex.patch673 bytesjohnalbin

Comments

johnalbin’s picture

Issue tags: +Accessibility
johnalbin’s picture

Title: Make containers be focus-able » Make containers accessible with tabindex focus
Everett Zufelt’s picture

Although I haven't used this module, I question why we would go to extra effort to make something focusable like a link, instead of making it a link? As much as is reasonably possible semantic markup is desired. By simply setting the item as focusable many AT users will not have any idea that the item is actionable.

A focusable span that reads "Menu" is confusing to a screen-reader user, if marked as an anchor or button this would read "Link: Menu" or "Button: Menu", providing a textual affordance for the available action.

johnalbin’s picture

Status: Active » Needs review
StatusFileSize
new673 bytes

Here's the patch I'm testing now on a test copy of Drupalcon Chicago.

johnalbin’s picture

Cross posted!

@Everett. Well, its not a link right now because there is no page to link to. We could add a <a href="#"> wrapper around the label, but I fear that might be worse since it would go nowhere. (Also, it would break the current touch device compatibility; though this is not important since we're building a mobile version of the Drupalcon site right now.)

By simply setting the item as focusable many AT users will not have any idea that the item is actionable.

It isn't actionable per se. It is just a container label that helps to organize its child links. The child menu items really are links that actionable.

Here's a sample of what the HTML would be (after the patch) for a container with child links:

johnalbin’s picture

Is there some additional accessible text I could add before the "Conference" label that would help with understanding the context?

The alternative is to make the "Conference" label link to the exact same page as "About Drupalcon". However, there's some technical issues with that approach since Drupal's menu system doesn't work well when there are 2 links with the same URL in one menu. Specifically, when you follow one of those links, Drupal has no idea which of the multiple links with the requested URL is the proper one to be the "active item", so it often highlights the "wrong" menu item from the user's perspective. I've been contemplating how to build a contrib module to get around that limitation.

Everett Zufelt’s picture

@John

Can you please wrap your example in code so I can more easily examine it? I do know that on the current Drupalcon site the links are not expanded by default. I don't see how this patch would change that.

If the links are not expanded by default, and require hover or focus to become expanded, then screen-reader users will still have a difficult time expanding the links. There needs to be some action (other than focus or hover) to expand the links for screen-reader users.

Thanks for working on this, fly out menus are very tricky to make accessible, primarily because there isn't really a good standard user interaction pattern for so doing.

Everett Zufelt’s picture

On the current site, if I use the virtual JAWS cursor (virtual buffer, or standard interaction mode) to find the first menu container "Conference", I can then route the actual mouse cursor to that item and the menu container expands. This is not particularly intuitive and some screen-reader users would not be able to perform this action.

johnalbin’s picture

Here's the example in code form:

<ul class="menu">
<li class="expanded first menu-mlid-11814"><span title="" class="menu-item-container" tabindex="0">Conference</span>
<ul class="menu"><li class="leaf first menu-mlid-1299"><a href="/conference" title="Overview">About DrupalCon</a></li>
<li class="leaf menu-mlid-12354 has-children"><a href="/sessions">Sessions</a></li>
<li class="leaf menu-mlid-11854"><a href="/keynotes" title="Keynotes">Keynotes</a></li>
<li class="leaf menu-mlid-11884"><a href="/conference/core" title="Core Conversations">Core Conversations</a></li>
<li class="leaf menu-mlid-3754"><a href="/training" title="">Pre-Conference Training</a></li>
<li class="leaf menu-mlid-1079 has-children"><a href="/sponsors">Sponsors</a></li>
<li class="leaf last menu-mlid-11909"><a href="/conference/schedule" title="Event Schedule">Event Schedule</a></li>
</ul>
</li>
</ul>
If the links are not expanded by default, and require hover or focus to become expanded, then screen-reader users will still have a difficult time expanding the links.

Yep. The mistake I made was putting a "display: none" on the child menu, which gets toggled on hover. I'm working on changing that to "overflow: hidden" and toggling it to "overflow: visible" on focus/hover. I'm hoping even without activating the toggled "overflow: visible" the child links will still be accessible.

I'll post a link to a test site once I've got it working in Safari's tab navigation.

johnalbin’s picture

So the patch for this module was the easy part.

But the javascript on the drupalcon chicago site was causing me serious grief. Since its a D6 site, it has an old version of jQuery 1.2.6 that doesn't support the focusin and focusout events that allow a container <li> to know if its children have keyboard focus.

I've implemented a usable, but less than ideal work-around for it.

Everett, do you think you could test this out? http://chicago2011.scratch.drupal.org You'll be prompted for a username/password before being able to see the site. Just use drupal for both username and password (all lowercase).

johnalbin’s picture

Oh, obviously the site chicago2011.scratch.drupal.org site is the development version of the site. If all works well, we'll push the changes to the production server.

Everett Zufelt’s picture

@John

Other than the fact that there are a lot of links to navigate through, which is annoying, this is working as well as can be expected for a screen-reader user. Is it working for keyboard only users, including visually displaying which item has focus?

johnalbin’s picture

Is it working for keyboard only users, including visually displaying which item has focus?

Yes, I tested in both Safari and Firefox using tab navigation and the links are visually displaying when tabbed to.

I'll get someone to push these changes to production. (Later today when they are awake.)

Thanks for your help Everett!

johnalbin’s picture

The module issue has been fixed with http://drupal.org/cvs?commit=486184

Leaving open until the Drupalcon Chicago module and javascript issues are fixed.

Crell’s picture

I've pushed another build to the DrupalCon Chicago site. John, Everett, please verify that everything is where it should be and is responding appropriately.

johnalbin’s picture

Status: Needs review » Fixed

It works the way I expected it to work. Thanks, Larry!

Everett (or anyone), please feel free to re-open if there are other a11y issues with the drupalcon nav. This is the easiest place to talk about it.

Status: Fixed » Closed (fixed)
Issue tags: -Accessibility

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