From db3b6ef6800127d8f4d53d4a72b83f1fbd5715e4 Mon Sep 17 00:00:00 2001 From: bnjmnm Date: Wed, 8 Dec 2021 12:32:38 -0500 Subject: [PATCH] fix issue 2002 by rewriting live region after delay --- ui/widgets/autocomplete.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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); } } );