]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: If the active element no longer exists after a refresh, blur the menu.
authorScott González <scott.gonzalez@gmail.com>
Mon, 27 Aug 2012 12:05:27 +0000 (08:05 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 27 Aug 2012 12:05:27 +0000 (08:05 -0400)
ui/jquery.ui.autocomplete.js
ui/jquery.ui.menu.js

index da10d82c5b79c585a95ab623e9e2beac03951348..80778f908d19213a2ff071c802e4cda569ed66db 100644 (file)
@@ -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
index 78b602cce55c6189e25c9672b28d45bb4a09d342..333bc9a38a45825a49fd25208b976ae77f28d6b3 100644 (file)
@@ -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() {