From 95feac1df5322ce3248d1286522fbec4460641f0 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Sun, 16 Oct 2016 20:02:33 +0000 Subject: [PATCH] Menus: Fix the posts-categories quick search. On the Menus screen, events that trigger the posts-categories search need to be delegated. This "boxes" may get dynamically rebuilt so events directly attached to the search input field need to be delegated. Fixes #38324. git-svn-id: https://develop.svn.wordpress.org/trunk@38799 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/nav-menu.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/js/nav-menu.js b/src/wp-admin/js/nav-menu.js index fdbc2eda22..3f8ee7b530 100644 --- a/src/wp-admin/js/nav-menu.js +++ b/src/wp-admin/js/nav-menu.js @@ -887,17 +887,21 @@ var wpNavMenu; inputEvent = 'keyup'; } - $( '.quick-search' ).on( inputEvent, function() { - var t = $(this); + $( '#nav-menu-meta' ).on( inputEvent, '.quick-search', function() { + var $this = $( this ); - if( searchTimer ) clearTimeout(searchTimer); + $this.attr( 'autocomplete', 'off' ); - searchTimer = setTimeout(function(){ - api.updateQuickSearchResults( t ); - }, 500 ); - }).on( 'blur', function() { + if ( searchTimer ) { + clearTimeout( searchTimer ); + } + + searchTimer = setTimeout( function() { + api.updateQuickSearchResults( $this ); + }, 500 ); + }).on( 'blur', '.quick-search', function() { api.lastSearch = ''; - }).attr('autocomplete','off'); + }); }, updateQuickSearchResults : function(input) {