Skip to content

Commit 93556a8

Browse files
committed
Menu: If the active element no longer exists after a refresh, blur the menu.
1 parent b22e3c3 commit 93556a8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,6 @@ $.widget( "ui.autocomplete", {
482482
.empty()
483483
.zIndex( this.element.zIndex() + 1 );
484484
this._renderMenu( ul, items );
485-
// TODO refresh should check if the active item is still in the dom, removing the need for a manual blur
486-
this.menu.blur();
487485
this.menu.refresh();
488486

489487
// size and position menu

ui/jquery.ui.menu.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ $.widget( "ui.menu", {
319319
.prepend( submenuCarat );
320320
menu.attr( "aria-labelledby", item.attr( "id" ) );
321321
});
322+
323+
// If the active item has been removed, blur the menu
324+
if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
325+
this.blur();
326+
}
322327
},
323328

324329
_itemRole: function() {

0 commit comments

Comments
 (0)