]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Only set the mouseHandled flag if the event is going to bubble. Fixes #9469...
authorTJ VanToll <tj.vantoll@gmail.com>
Fri, 2 Aug 2013 10:51:04 +0000 (06:51 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 26 Nov 2013 19:46:41 +0000 (14:46 -0500)
not firing every time.
(cherry picked from commit 484e382259f1c1c56b151a97ddf8a894f94d17ea)

tests/unit/menu/menu_events.js
ui/jquery.ui.menu.js

index 554c4c51603be5e909c2d88b13d312f313ffc8e9..4b152dcf497dbddfe68f6c5a35db20ec7d26107c 100644 (file)
@@ -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." );
 });
 
+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 );
index b2ad765665ae7c354891bf7c4ebb580e48e7003d..93309f7f115780ebdc379dd217435f55e141eb92 100644 (file)
@@ -75,9 +75,13 @@ $.widget( "ui.menu", {
                        "click .ui-menu-item:has(a)": function( event ) {
                                var target = $( event.target ).closest( ".ui-menu-item" );
                                if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
-                                       this.mouseHandled = true;
-
                                        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
                                        if ( target.has( ".ui-menu" ).length ) {
                                                this.expand( event );