From 190b9a0b32b40a67a6f0045921a67e09a52eceb1 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 30 Nov 2020 14:31:04 +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. Built from https://develop.svn.wordpress.org/trunk@49710 git-svn-id: http://core.svn.wordpress.org/trunk@49433 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/tags-suggest.js | 21 ++++++++++++--------- wp-admin/js/tags-suggest.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/wp-admin/js/tags-suggest.js b/wp-admin/js/tags-suggest.js index 7a19002a4c..0381f0053c 100644 --- a/wp-admin/js/tags-suggest.js +++ b/wp-admin/js/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. diff --git a/wp-admin/js/tags-suggest.min.js b/wp-admin/js/tags-suggest.min.js index e93b991536..1e76c54e2c 100644 --- a/wp-admin/js/tags-suggest.min.js +++ b/wp-admin/js/tags-suggest.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(u){if(void 0!==window.uiAutocompleteL10n){var s=0,a=wp.i18n._x(",","tag delimiter")||",";u.fn.wpTagsSuggest=function(e){var i,o,n=u(this);if(n.length){var r=(e=e||{}).taxonomy||n.attr("data-wp-taxonomy")||"post_tag";return delete e.taxonomy,e=u.extend({source:function(e,a){var t;o!==e.term?(t=function(e){return l(e).pop()}(e.term),u.get(window.ajaxurl,{action:"ajax-tag-search",tax:r,q:t}).always(function(){n.removeClass("ui-autocomplete-loading")}).done(function(e){var t,o=[];if(e){for(t in e=e.split("\n")){var n=++s;o.push({id:n,name:e[t]})}a(i=o)}else a(o)}),o=e.term):a(i)},focus:function(e,t){n.attr("aria-activedescendant","wp-tags-autocomplete-"+t.item.id),e.preventDefault()},select:function(e,t){var o=l(n.val());return o.pop(),o.push(t.item.name,""),n.val(o.join(a+" ")),u.ui.keyCode.TAB===e.keyCode?(window.wp.a11y.speak(wp.i18n.__("Term selected."),"assertive"),e.preventDefault()):u.ui.keyCode.ENTER===e.keyCode&&(window.tagBox&&(window.tagBox.userAction="add",window.tagBox.flushTags(u(this).closest(".tagsdiv"))),e.preventDefault(),e.stopPropagation()),!1},open:function(){n.attr("aria-expanded","true")},close:function(){n.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2",at:"left bottom",collision:"none"},messages:{noResults:window.uiAutocompleteL10n.noResults,results:function(e){return 1').text(t.name).appendTo(e)}),n.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":n.autocomplete("widget").attr("id")}).on("focus",function(){l(n.val()).pop()&&n.autocomplete("search")}).autocomplete("widget").addClass("wp-tags-autocomplete").attr("role","listbox").removeAttr("tabindex").on("menufocus",function(e,t){t.item.attr("aria-selected","true")}).on("menublur",function(){u(this).find('[aria-selected="true"]').removeAttr("aria-selected")}),this}}}function l(e){return e.split(new RegExp(a+"\\s*"))}}(jQuery); \ No newline at end of file +!function(u){if(void 0!==window.uiAutocompleteL10n){var s=0,a=wp.i18n._x(",","tag delimiter")||",";u.fn.wpTagsSuggest=function(e){var i,o,n=u(this);if(!n.length)return this;var r=(e=e||{}).taxonomy||n.attr("data-wp-taxonomy")||"post_tag";return delete e.taxonomy,e=u.extend({source:function(e,a){var t;o!==e.term?(t=function(e){return l(e).pop()}(e.term),u.get(window.ajaxurl,{action:"ajax-tag-search",tax:r,q:t}).always(function(){n.removeClass("ui-autocomplete-loading")}).done(function(e){var t,o=[];if(e){for(t in e=e.split("\n")){var n=++s;o.push({id:n,name:e[t]})}a(i=o)}else a(o)}),o=e.term):a(i)},focus:function(e,t){n.attr("aria-activedescendant","wp-tags-autocomplete-"+t.item.id),e.preventDefault()},select:function(e,t){var o=l(n.val());return o.pop(),o.push(t.item.name,""),n.val(o.join(a+" ")),u.ui.keyCode.TAB===e.keyCode?(window.wp.a11y.speak(wp.i18n.__("Term selected."),"assertive"),e.preventDefault()):u.ui.keyCode.ENTER===e.keyCode&&(window.tagBox&&(window.tagBox.userAction="add",window.tagBox.flushTags(u(this).closest(".tagsdiv"))),e.preventDefault(),e.stopPropagation()),!1},open:function(){n.attr("aria-expanded","true")},close:function(){n.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2",at:"left bottom",collision:"none"},messages:{noResults:window.uiAutocompleteL10n.noResults,results:function(e){return 1').text(t.name).appendTo(e)},n.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":n.autocomplete("widget").attr("id")}).on("focus",function(){l(n.val()).pop()&&n.autocomplete("search")}),n.autocomplete("widget").addClass("wp-tags-autocomplete").attr("role","listbox").removeAttr("tabindex").on("menufocus",function(e,t){t.item.attr("aria-selected","true")}).on("menublur",function(){u(this).find('[aria-selected="true"]').removeAttr("aria-selected")})),this}}function l(e){return e.split(new RegExp(a+"\\s*"))}}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 6dd10274fe..6d6646d150 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-49709'; +$wp_version = '5.7-alpha-49710'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.