diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js
index 4166029b2ed..a3af2b6e185 100644
--- a/ui/widgets/autocomplete.js
+++ b/ui/widgets/autocomplete.js
@@ -66,6 +66,7 @@ $.widget( "ui.autocomplete", {
requestIndex: 0,
pending: 0,
+ liveRegionTimer: null,
_create: function() {
@@ -267,8 +268,10 @@ $.widget( "ui.autocomplete", {
// Announce the value in the liveRegion
label = ui.item.attr( "aria-label" ) || item.value;
if ( label && String.prototype.trim.call( label ).length ) {
- this.liveRegion.children().hide();
- $( "
" ).text( label ).appendTo( this.liveRegion );
+ clearTimeout( this.liveRegionTimer );
+ this.liveRegionTimer = setTimeout(() => {
+ this.liveRegion.html($( "
" ).text( label ));
+ }, 400);
}
},
menuselect: function( event, ui ) {
@@ -663,8 +666,10 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
} else {
message = this.options.messages.noResults;
}
- this.liveRegion.children().hide();
- $( "
" ).text( message ).appendTo( this.liveRegion );
+ clearTimeout( this.liveRegionTimer );
+ this.liveRegionTimer = setTimeout(() => {
+ this.liveRegion.html($( "
" ).text( message ));
+ }, 400);
}
} );