From 0d25a36eecb9e5598596208e4852b3c3fdbf5510 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 18 Apr 2017 17:37:15 -0400 Subject: [PATCH] Menu: Close menus immediately on selection or click outside Fixes #15034 Closes gh-1807 --- tests/unit/menu/events.js | 4 +++- ui/widgets/menu.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js index a8ccb0282..90507bddc 100644 --- a/tests/unit/menu/events.js +++ b/tests/unit/menu/events.js @@ -670,7 +670,9 @@ QUnit.test( "handle keyboard navigation and mouse click on menu with dividers an element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - assert.equal( logOutput(), "keydown,3,4,7", "Keydown focus skips divider and group label" ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + assert.equal( logOutput(), "keydown,1,2,3,4,7", "Keydown focus skips divider and group label" ); ready(); } } ); diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 49da26865..19d9b90df 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -162,7 +162,7 @@ return $.widget( "ui.menu", { this._on( this.document, { click: function( event ) { if ( this._closeOnDocumentClick( event ) ) { - this.collapseAll( event ); + this.collapseAll( event, true ); } // Reset the mouseHandled flag @@ -502,7 +502,7 @@ return $.widget( "ui.menu", { this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" ); this.activeMenu = currentMenu; - }, this.delay ); + }, all ? 0 : this.delay ); }, // With no arguments, closes the currently active menu - if nothing is active -- 2.39.5