diff --git a/lib/web/mage/menu.js b/lib/web/mage/menu.js index a47e2efdb8d1..ed958adf3364 100644 --- a/lib/web/mage/menu.js +++ b/lib/web/mage/menu.js @@ -437,6 +437,22 @@ define([ target = $(event.target).closest('.ui-menu-item'); target.get(0).scrollIntoView(); + // Open submenu on click + if (target.has('.ui-menu').length) { + this.expand(event); + } else if (!this.element.is(':focus') && + $(this.document[0].activeElement).closest('.ui-menu').length + ) { + // Redirect focus to the menu + this.element.trigger('focus', [true]); + + // If the active item is on the top level, let it stay active. + // Otherwise, blur the active item since it is no longer visible. + if (this.active && this.active.parents('.ui-menu').length === 1) { //eslint-disable-line + clearTimeout(this.timer); + } + } + if (!target.hasClass('level-top') || !target.has('.ui-menu').length) { window.location.href = target.find('> a').attr('href'); }