mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Menu: Only set the mouseHandled flag if the event is going to bubble. Fixes #9469: on( "menuselect" )
not firing every time.
(cherry picked from commit 484e382259
)
This commit is contained in:
parent
1a2284deb6
commit
b02a32f4b3
@ -619,4 +619,19 @@ test( "ensure default is prevented when clicking on anchors in disabled menus ",
|
|||||||
equal( logOutput(), "click,1,afterclick,disable,enable,3", "Click order not valid." );
|
equal( logOutput(), "click,1,afterclick,disable,enable,3", "Click order not valid." );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "#9469: Stopping propagation in a select event should not suppress subsequent select events.", function() {
|
||||||
|
expect( 1 );
|
||||||
|
var element = $( "#menu1" ).menu({
|
||||||
|
select: function( event, ui ) {
|
||||||
|
log();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
click( element, "1" );
|
||||||
|
click( element, "2" );
|
||||||
|
|
||||||
|
equal( logOutput(), "1,2", "Both select events were not triggered." );
|
||||||
|
});
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
8
ui/jquery.ui.menu.js
vendored
8
ui/jquery.ui.menu.js
vendored
@ -75,9 +75,13 @@ $.widget( "ui.menu", {
|
|||||||
"click .ui-menu-item:has(a)": function( event ) {
|
"click .ui-menu-item:has(a)": function( event ) {
|
||||||
var target = $( event.target ).closest( ".ui-menu-item" );
|
var target = $( event.target ).closest( ".ui-menu-item" );
|
||||||
if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
|
if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
|
||||||
this.mouseHandled = true;
|
|
||||||
|
|
||||||
this.select( event );
|
this.select( event );
|
||||||
|
|
||||||
|
// Only set the mouseHandled flag if the event will bubble, see #9469.
|
||||||
|
if ( !event.isPropagationStopped() ) {
|
||||||
|
this.mouseHandled = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Open submenu on click
|
// Open submenu on click
|
||||||
if ( target.has( ".ui-menu" ).length ) {
|
if ( target.has( ".ui-menu" ).length ) {
|
||||||
this.expand( event );
|
this.expand( event );
|
||||||
|
Loading…
Reference in New Issue
Block a user