From 93556a8e18be972d487498a42b3916f8fff9e995 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 27 Aug 2012 08:05:27 -0400 Subject: [PATCH] Menu: If the active element no longer exists after a refresh, blur the menu. --- ui/jquery.ui.autocomplete.js | 2 -- ui/jquery.ui.menu.js | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) 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() { -- 2.39.5