Issue #2103247 by Tom Verhaeghe | stpaultim: Fixed Clicking menu links in the administration menu tray should close the admin menu tray, while in a narrow viewport where the toolbar is positioned on top of the content.

8.0.x
Alex Pott 2014-11-18 12:27:55 +00:00
parent 547a1a0de7
commit 7c37dac7e6
1 changed files with 20 additions and 1 deletions

View File

@ -37,6 +37,23 @@
toggleList($openItems, false);
}
/**
* Handle clicks from a menu item link.
*
* @param {Object} event
* A jQuery Event object.
*/
function linkClickHandler(event) {
// If the toolbar is positioned fixed (and therefore hiding content
// underneath), then users expect clicks in the administration menu tray
// to take them to that destination but for the menu tray to be closed
// after clicking: otherwise the toolbar itself is obstructing the view
// of the destination they chose.
if (!Drupal.toolbar.models.toolbarModel.get('isFixed')) {
Drupal.toolbar.models.toolbarModel.set('activeTab', null);
}
}
/**
* Toggle the open/close state of a list is a menu.
*
@ -136,7 +153,9 @@
// Bind event handlers.
$(document)
.on('click.toolbar', '.toolbar-handle', toggleClickHandler);
.on('click.toolbar', '.toolbar-handle', toggleClickHandler)
.on('click.toolbar', '.toolbar-box a', linkClickHandler);
// Return the jQuery object.
return this.each(function (selector) {
var $menu = $(this).once('toolbar-menu');