From 50d948daf4205c815ce838e8a875f3e91214d16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 25 Aug 2019 17:18:26 +0200 Subject: [PATCH] Ignore Enter key up event on menu button toggles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like links, buttons generate a "click" event as well as the regular "keydown" and "keyup" events when pressing Enter. Due to this, if both the "click" and the "keyup" events are handled, when the menu is open and Enter is pressed in the toggle the menu is first hidden when the first event is handled, but then shown again when the second event is handled. To prevent that only the "click" event should be handled when the toggle is a button, like it is already done with links. Signed-off-by: Daniel Calviño Sánchez --- core/js/js.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index c1b93a85e3bfb..0d434722c6064 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -640,9 +640,9 @@ Object.assign(window.OC, { var self = this; $menuEl.addClass('menu'); - // On link, the enter key trigger a click event + // On link and button, the enter key trigger a click event // Only use the click to avoid two fired events - $toggle.on($toggle.prop('tagName') === 'A' + $toggle.on(($toggle.prop('tagName') === 'A' || $toggle.prop('tagName') === 'BUTTON') ? 'click.menu' : 'click.menu keyup.menu', function(event) { // prevent the link event (append anchor to URL)