From 69c3ab8a118679b3f560b7f332068e180d6d7310 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 30 Nov 2020 14:29:42 +0000 Subject: [PATCH] Quick/Bulk Edit: Follow up to [49703]. Improve the logic a bit and always return `this` (the jQuery object) in `wpTagsSuggest`. Fixes #51872. git-svn-id: https://develop.svn.wordpress.org/trunk@49710 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/tags-suggest.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/js/_enqueues/admin/tags-suggest.js b/src/js/_enqueues/admin/tags-suggest.js index 7a19002a4c..0381f0053c 100644 --- a/src/js/_enqueues/admin/tags-suggest.js +++ b/src/js/_enqueues/admin/tags-suggest.js @@ -40,7 +40,7 @@ // Do not initialize if the element doesn't exist. if ( ! $element.length ) { - return; + return this; } options = options || {}; @@ -156,14 +156,16 @@ $element.autocomplete( options ); // Ensure the autocomplete instance exists. - if ( $element.autocomplete( 'instance' ) ) { - $element.autocomplete( 'instance' )._renderItem = function( ul, item ) { - return $( '
  • ' ) - .text( item.name ) - .appendTo( ul ); - }; + if ( ! $element.autocomplete( 'instance' ) ) { + return this; } + $element.autocomplete( 'instance' )._renderItem = function( ul, item ) { + return $( '
  • ' ) + .text( item.name ) + .appendTo( ul ); + }; + $element.attr( { 'role': 'combobox', 'aria-autocomplete': 'list', @@ -178,9 +180,10 @@ if ( inputValue ) { $element.autocomplete( 'search' ); } - } ) + } ); + // Returns a jQuery object containing the menu element. - .autocomplete( 'widget' ) + $element.autocomplete( 'widget' ) .addClass( 'wp-tags-autocomplete' ) .attr( 'role', 'listbox' ) .removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI.