mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu: Remove most event.stopImmediatePropagation() to allow proper event bubbling
This commit is contained in:
parent
d22edc8d05
commit
26d6952bd2
43
ui/jquery.ui.menu.js
vendored
43
ui/jquery.ui.menu.js
vendored
@ -13,7 +13,8 @@
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
var idIncrement = 0;
|
||||
var idIncrement = 0,
|
||||
currentEventTarget;
|
||||
|
||||
$.widget( "ui.menu", {
|
||||
version: "@VERSION",
|
||||
@ -66,9 +67,14 @@ $.widget( "ui.menu", {
|
||||
event.preventDefault();
|
||||
},
|
||||
"click .ui-menu-item:has(a)": function( event ) {
|
||||
event.stopImmediatePropagation();
|
||||
var target = $( event.target );
|
||||
if ( target[0] != currentEventTarget ) {
|
||||
currentEventTarget = target[0];
|
||||
target.one( "click", function( event ) {
|
||||
currentEventTarget = "";
|
||||
});
|
||||
// Don't select disabled menu items
|
||||
if ( !$( event.target ).closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
|
||||
if ( !target.closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
|
||||
this.select( event );
|
||||
// Redirect focus to the menu with a delay for firefox
|
||||
this._delay(function() {
|
||||
@ -77,6 +83,7 @@ $.widget( "ui.menu", {
|
||||
}
|
||||
}, 20 );
|
||||
}
|
||||
}
|
||||
},
|
||||
"mouseover .ui-menu-item": function( event ) {
|
||||
event.stopImmediatePropagation();
|
||||
@ -158,65 +165,49 @@ $.widget( "ui.menu", {
|
||||
case $.ui.keyCode.PAGE_UP:
|
||||
this.previousPage( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.PAGE_DOWN:
|
||||
this.nextPage( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.HOME:
|
||||
this._move( "first", "first", event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.END:
|
||||
this._move( "last", "last", event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.UP:
|
||||
this.previous( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.DOWN:
|
||||
this.next( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.LEFT:
|
||||
if (this.collapse( event )) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
this.collapse( event );
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.RIGHT:
|
||||
if (this.expand( event )) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
this.expand( event );
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.ENTER:
|
||||
if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
|
||||
if ( this.expand( event ) ) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
this.expand( event );
|
||||
}
|
||||
else {
|
||||
this.select( event );
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.ESCAPE:
|
||||
if ( this.collapse( event ) ) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
this.collapse( event );
|
||||
event.preventDefault();
|
||||
break;
|
||||
default:
|
||||
event.stopPropagation();
|
||||
clearTimeout( this.filterTimer );
|
||||
var match,
|
||||
prev = this.previousFilter || "",
|
||||
@ -303,7 +294,7 @@ $.widget( "ui.menu", {
|
||||
|
||||
focus: function( event, item ) {
|
||||
var nested, borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
|
||||
this.blur( event );
|
||||
this.blur( event, event.type == "focus" );
|
||||
|
||||
if ( this._hasScroll() ) {
|
||||
borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
|
||||
@ -342,8 +333,10 @@ $.widget( "ui.menu", {
|
||||
this._trigger( "focus", event, { item: item } );
|
||||
},
|
||||
|
||||
blur: function( event ) {
|
||||
blur: function( event, fromFocus ) {
|
||||
if ( !fromFocus ) {
|
||||
clearTimeout( this.timer );
|
||||
}
|
||||
|
||||
if ( !this.active ) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user