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
This commit is contained in:
Andrew Ozz
2020-11-30 14:29:42 +00:00
parent 19864318cc
commit 69c3ab8a11

View File

@@ -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 $( '<li role="option" id="wp-tags-autocomplete-' + item.id + '">' )
.text( item.name )
.appendTo( ul );
};
if ( ! $element.autocomplete( 'instance' ) ) {
return this;
}
$element.autocomplete( 'instance' )._renderItem = function( ul, item ) {
return $( '<li role="option" id="wp-tags-autocomplete-' + item.id + '">' )
.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.