Skip to content

Commit 9a274c0

Browse files
committed
Menu: Check if menu is scrolling to prevent inadvertent mouseover events from being fired on scroll
1 parent 75415b3 commit 9a274c0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ui/jquery.ui.menu.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $.widget( "ui.menu", {
2828
},
2929
_create: function() {
3030
this.activeMenu = this.element;
31+
this.isScrolling = false;
3132
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
3233
if ( this.element.find( ".ui-icon" ).length ) {
3334
this.element.addClass( "ui-menu-icons" );
@@ -57,10 +58,13 @@ $.widget( "ui.menu", {
5758
},
5859
"mouseover .ui-menu-item": function( event ) {
5960
event.stopImmediatePropagation();
60-
var target = $( event.currentTarget );
61-
// Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
62-
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
63-
this.focus( event, target );
61+
if ( !this.isScrolling ) {
62+
var target = $( event.currentTarget );
63+
// Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
64+
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
65+
this.focus( event, target );
66+
}
67+
this.isScrolling = false;
6468
},
6569
"mouseleave": "collapseAll",
6670
"mouseleave .ui-menu": "collapseAll",
@@ -74,6 +78,10 @@ $.widget( "ui.menu", {
7478
this.collapseAll( event );
7579
}
7680
}, 0);
81+
},
82+
scroll: function( event ) {
83+
// Keep track of scrolling to prevent mouseover from firing inadvertently when scrolling the menu
84+
this.isScrolling = true;
7785
}
7886
});
7987

0 commit comments

Comments
 (0)