From: Daniel Calviño Sánchez Date: Sun, 25 Aug 2019 15:18:26 +0000 (+0200) Subject: Ignore Enter key up event on menu button toggles X-Git-Tag: v16.0.5RC1~31^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=50d948daf4205c815ce838e8a875f3e91214d16c;p=nextcloud-server.git Ignore Enter key up event on menu button toggles 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 --- diff --git a/core/js/js.js b/core/js/js.js index c1b93a85e3b..0d434722c60 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)