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 <danxuliu@gmail.com>
This commit is contained in:
parent
fc9f12d72d
commit
50d948daf4
|
@ -640,9 +640,9 @@ Object.assign(window.OC, {
|
||||||
var self = this;
|
var self = this;
|
||||||
$menuEl.addClass('menu');
|
$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
|
// 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'
|
||||||
: 'click.menu keyup.menu', function(event) {
|
: 'click.menu keyup.menu', function(event) {
|
||||||
// prevent the link event (append anchor to URL)
|
// prevent the link event (append anchor to URL)
|
||||||
|
|
Loading…
Reference in New Issue