From: Scott González Date: Mon, 27 Aug 2012 12:05:27 +0000 (-0400) Subject: Menu: If the active element no longer exists after a refresh, blur the menu. X-Git-Tag: 1.9.0~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=93556a8e18be972d487498a42b3916f8fff9e995;p=jquery-ui.git Menu: If the active element no longer exists after a refresh, blur the menu. --- diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index da10d82c5..80778f908 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -482,8 +482,6 @@ $.widget( "ui.autocomplete", { .empty() .zIndex( this.element.zIndex() + 1 ); this._renderMenu( ul, items ); - // TODO refresh should check if the active item is still in the dom, removing the need for a manual blur - this.menu.blur(); this.menu.refresh(); // size and position menu diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 78b602cce..333bc9a38 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -319,6 +319,11 @@ $.widget( "ui.menu", { .prepend( submenuCarat ); menu.attr( "aria-labelledby", item.attr( "id" ) ); }); + + // If the active item has been removed, blur the menu + if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { + this.blur(); + } }, _itemRole: function() {