Problem/Motivation
The Toolbar Items element does not render "Tray items" within the same container as their associated parent Toolbar item (the attached screenshot provides some visual clarity).
To explain:
When I click a UI element that "controls" another, then the association must be maintained:
As a keyboard only user:
- I use the tab key to navigate keyboard Focus to the Tab-toolbar
- I then hit the enter key to "expand" (and make visually available) a Toolbar item's Tray (child items)
- I then TRY to use the tab key to continue to navigate this widget (which looks like a menu structure) so that Focus is placed on one of the newly revealed items... this does not work... instead of the Focus moving to the first-in-DOM-order item in the Tray, the Focus moves to the next Tab item on the Toolbar
Proposed resolution
Please update the rendering order (via HTML template according to @jessebeach) so that Tray items are output within the same container as their controlling parent element.
I'm providing a code example just below.
Current Markup
<nav role="navigation" class="toolbar toolbar-processed toolbar-oriented" id="toolbar-administration">
<div class="toolbar-bar clearfix" id="toolbar-bar" data-offset-top="">
<h2 class="visually-hidden">Toolbar items</h2>
<!-- Home link ... -->
<div class="toolbar-tab">
<a href="/admin">Menu</a>
</div>
<div class="toolbar-tab">
<a href="/admin/config/user-interface/shortcut">Shortcuts</a>
</div>
<!-- Other parent Tabs... -->
</div>
<div id="toolbar-item--2-tray" class="toolbar-tray active toolbar-tray-horizontal">
<div class="toolbar-lining clearfix">
<h3 class="toolbar-tray-name visually-hidden">Administration menu</h3>
<div class="toolbar-menu-administration">
<ul class="menu clearfix">
<li class="first collapsed">
<a href="/admin/content">Content</a>
</li>
<!-- Other menu items... -->
</ul>
</div>
</div>
</div>
<div id="toolbar-item--3-tray" class="toolbar-tray toolbar-tray-horizontal">
<div class="toolbar-lining clearfix">
<h3 class="toolbar-tray-name visually-hidden">User-defined shortcuts</h3>
<ul class="menu">
<li class="first leaf"><a href="/node/add">Add content</a></li>
<li class="last leaf"><a href="/admin/content">All content</a></li>
</ul>
<a class="edit-shortcuts" href="/admin/config/user-interface/shortcut/manage/default">Edit shortcuts</a>
</div>
</div>
<!-- Other Tray items... -->
</nav>
Desired Markup
<nav role="navigation" class="toolbar toolbar-processed toolbar-oriented" id="toolbar-administration">
<div class="toolbar-bar clearfix" id="toolbar-bar" data-offset-top="">
<h2 class="visually-hidden">Toolbar items</h2>
<!-- Toolbar Parent Wrapper -->
<div class="toolbar-tab">
<!-- Toggle -->
<a href="/admin">Menu</a>
<!-- Tray -->
<div id="toolbar-item--2-tray" class="toolbar-tray active toolbar-tray-horizontal">
<div class="toolbar-lining clearfix">
<h3 class="toolbar-tray-name visually-hidden">Administration menu</h3>
<div class="toolbar-menu-administration">
<ul class="menu clearfix">
<li class="first collapsed"><a href="/admin/content">Content</a></li>
<!-- Other menu items... -->
</ul>
</div>
</div>
</div>
</div>
<!-- Toolbar Parent Wrapper -->
<div class="toolbar-tab">
<!-- Toggle -->
<a href="/admin/config/user-interface/shortcut">Shortcuts</a>
<!-- Tray -->
<div id="toolbar-item--3-tray" class="toolbar-tray toolbar-tray-horizontal">
<div class="toolbar-lining clearfix">
<h3 class="toolbar-tray-name visually-hidden">User-defined shortcuts</h3>
<ul class="menu">
<li class="first leaf"><a href="/node/add">Add content</a></li>
<li class="last leaf"><a href="/admin/content">All content</a>
</li>
</ul>
<a class="edit-shortcuts" href="/admin/config/user-interface/shortcut/manage/default">Edit shortcuts</a>
</div>
</div>
</div>
<!-- Other Toolbar Parent Wrappers -->
</div>
</nav>
User interface changes
Using only a keyboard, we will be able to navigate and use the various Toolbars/Trays within the Toolbar correctly. Navigation of these elements should be possible via tab
and arrow
keys.
Once a Tray is expanded, the user's tab and arrow keys and (for screen readers) "virtual cursor" should be limited to to the Tray, this article will help: The Incredible Accessible Modal Dialog.
Comment | File | Size | Author |
---|---|---|---|
#51 | interdiff.txt | 1.24 KB | idflood |
#51 | 2173527-50.patch | 6.66 KB | idflood |
#44 | Nested-vertical.png | 98.31 KB | mgifford |
#44 | Nested-Horizontal.png | 93.87 KB | mgifford |
Comments
Comment #1
anandkp CreditAttribution: anandkp commentedComment #2
crasx CreditAttribution: crasx commentedCould we modify the twig file in core/modules/toolbar/template/?
We would delete the second for loop and its contents to the first for loop. Check if the current array index exists in the second array, if it does print out that div.
this may also break some javascript or css so that would need to be modified
Comment #3
nod_It's fine to break stuff, get the patch as far as you can and jump in on IRC #drupal-contribute to get help to get the patch even further :)
Comment #4
anandkp CreditAttribution: anandkp commentedAwesome to see your interest @nod_, @crasx!
I'm in the middle of moving residences so I'm gonna unassign this from myself.
Comment #5
anandkp CreditAttribution: anandkp commentedComment #6
Sam152 CreditAttribution: Sam152 commentedThis was an interesting patch, I expect it to have a few issues, but it’s good to get the ball rolling. I have tried the keyboard navigation out with the patch applied and I can definitely see the advantages.
A few things to note:
My biggest annoyance was dealing with "toolbar-lining” and its :before element. It was appearing over the parent toolbar items, and top could not be set dynamically (as it’s not part of the DOM). If we could hard-code the height of the bar, it wouldn't be an issue, but this isn’t how the rest of the toolbar handles it. Can someone confirm we still need this lining? It doesn't seem to break anything in chrome by simply removing it. I got around this by bringing the top level menu items above it, but I'm not totally satisfied with this.
If you are providing a review, please test under different orientations and screen sizes.
Comment #7
nod_That's a pretty important patch to allow us to simplify the JS behind toolbar #2145365: Make toolbar rendering fast.
Not sure about the acordion-ification of the menu though. I personally do not use the dropdown menu so I don't really care either way.
Comment #8
falcon03 CreditAttribution: falcon03 commentedJust wanted to point out:
#1800614: Improve the responsive toolbar accessibility
and especially comment#6 of that issue...
Comment #9
nod_Patch looks really good but the a11y implications are not clear to me. Seems like your comment in the other issue suggest another solution than keeping tabs and trays separated might be possible.
Comment #10
mgiffordThe patch from February 15 still applies.
The accessibility challenge is that when someone is just using a keyboard to navigate a site, if they hit the Menu toolbar it expands nicely, but the next tab doesn't go to Content, which is the first item in the expanded menu, but rather you have to tab to Shortcuts and then over to admin before you get to the Content tab.
The logical assumption is that if you open the Menu toolbar you might want to use it.
The patch addresses this issue nicely. With the patch it allows keyboard only users to more quickly get to the information they need.
I think this is RTBC.
Comment #11
jessebeach CreditAttribution: jessebeach commentedIt's in my queue to review.
Comment #12
Liam MorlandComment #14
mgiffordWould be great to get this reviewed in TwinCities DC.
Comment #15
mgiffordComment #16
mgiffordComment #18
scresante CreditAttribution: scresante commentedI re-rolled the patch and it looks like it works, could someone review?
Comment #19
mgiffordOften useful to provide an interdiff.
Found this still in the CSS
Should be an easy thing to remove.
That doesn't break the installation process - http://sd12046bf51ce36a.s2.simplytest.me
This causes other CSS issues.
Comment #20
scresante CreditAttribution: scresante commentedRe-rolled, without git markers. The interdiff fails, but the patch applies cleanly. Removed an unmatched < /div > as well
Comment #23
mgiffordThere seems to be a missing
<div>
tag when I look at the source.One of the last two
</div>
's is reported as being extra..EDIT: Other than that it is great. Think it's very close to RTBC.
Comment #24
tim.plunkettComment #25
scresante CreditAttribution: scresante commentedThe patch applies cleanly. It doesn't need a reroll anymore, but perhaps just the removal of an extraneous element. I will check that now.
Comment #26
scresante CreditAttribution: scresante commentedI don't know where that extra div is coming from. Please check toolbar.html.twig after applying the patch. I can't see anything wrong with it, but I'm new to twig.
Comment #27
mgiffordComment #28
Wim LeersNo longer applies.
Comment #29
rpayanmThe patch #20 removed the tag
</nav>
for that maybe is the issue of the<div>
.Also I fix a typo in core/modules/toolbar/css/toolbar.module.css
to:
Here the reroll.
Comment #30
Wim LeersPlease use spaces instead of tabs.
Comment #32
rpayanmComment #34
Wim LeersThere are testbot problems ATM, these are the actual failures:
Comment #39
mgiffordJust a re-roll. I don't know enough about how the CSS file has changed to do much more than copy the added text over.
Comment #40
mgiffordIt doesn't look like we are any closer to having nested elements in the same container as their parent toolbar item...
Comment #41
idflood CreditAttribution: idflood as a volunteer commentedHere is a new patch which also patch the toolbar.html.twig defined in the classy theme. This should fix the issued described in #40.
Comment #43
idflood CreditAttribution: idflood as a volunteer commentedThis one fix the new failing test.
Comment #44
mgiffordI'm ready to mark this RTBC. I've tested it in Chrome, FF, IE. Also reviewed it on my Android phone.
The code looks good, there are tests and it would be great to get this in. Screenshots are attached showing the nested code.
Comment #45
Wim Leers.toolbar-tab .toolbar-tab
This looks extremely weird.
Please document why the specific value of 502 was chosen. Also, needs space after the colon.
Nice :)
We lost this
role="navigation"
. I'm assuming this was intentional, but I'd like explicit confirmation.And why did this
<nav>
become a<div>
?Comment #46
mgifford1) That can't be correct...
That slipped by me.EDIT: But it is.toolbar-bar .toolbar-tab
2) Is there a standard for what the z-index should be?
3) :)
4)
role="navigation"
&<nav>
should remain. I should have seen that... Too distracted these days. Sorry.Comment #47
Wim Leers1. Oops! Then my next question: why is the
>
necessary?2. Not really, but 502 seems very... random. And hence feels/seems like a hack.
Comment #48
idflood CreditAttribution: idflood as a volunteer commentedHere is a new patch which should fix the issues discussed in #45 #46 #47.
1. I think the
>
is required now because this target the icons on the "first level" toolbar (the icons on the black bar). And now that the tray items are nested in it they can also have.toolbar-icon
inside them.2. The 502 might have been chosen because the
.toolbar .toolbar-tray
has a z-index of 501. With something lower the links become unclickable. This is also consistent with the.toolbar-oriented .toolbar-bar
which has a z-index of 502 too and this comment: "Layer the bar just above the trays and above contextual link triggers."Comment #49
Wim Leers1. That makes sense, thanks.
2. Thanks for adding a comment to the CSS for that.
I'm now fine with this being committed, I'll let @mgifford mark it as RTBC again. (Wanna make sure that the markup changes indeed don't adversely affect the accessibility.)
Comment #51
idflood CreditAttribution: idflood as a volunteer commentedI forgot to change the test again.
Comment #52
mgiffordThis looks good now. I reviewed the interdiff. Thanks for adding back in the
role="navigation"
&<nav>
I've tested it in FF & Chrome. I found another issue with the toolbar by doing the review, but I'll post that separately. It's unrelated to the patch.
Comment #53
alexpottAccessibility is a prioritized change during beta. Committed 184d4b4 and pushed to 8.0.x. Thanks!
Comment #55
pp CreditAttribution: pp as a volunteer commentedWhy did you delete
aria-label="{{ tray.label }}"
from core/modules/toolbar/templates/toolbar.html.twig?Comment #56
nod_It's from the original patch and hasn't been put in question since.
Reading #1800614-6: Improve the responsive toolbar accessibility makes it clear it should be kept so it needs to be added back. Opened new issue for it (since a new patch after it's been committed gets in the way of the workflow).
Please review #2548027: Follow-up add back aria-label to toolbar tray for the fix.
Comment #57
Wim LeersAnd another regression: the orientation toggling arrows: #2546196: Toolbar's orientation-toggling arrows broken by #2173527.