From 7b9c810b9ac450d826b6fa0c3d35377178b7e3b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=CC=88rn=20Zaefferer?= Date: Fri, 18 Oct 2013 15:39:20 +0200 Subject: [PATCH] Autocomplete: Append liveRegion to body to support detached init. Fixes #9590 - Dynamically adding input field breaks auto-complete's accessibility for screen readers --- tests/unit/autocomplete/autocomplete_core.js | 9 +++++++++ ui/jquery.ui.autocomplete.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index a8b0a7330..58e96755a 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -257,6 +257,15 @@ test( "ARIA", function() { "Live region for multiple values" ); }); +test( "ARIA, init on detached input", function() { + expect( 1 ); + var element = $( "" ).autocomplete({ + source: [ "java", "javascript" ] + }), + liveRegion = element.autocomplete( "instance" ).liveRegion; + equal( liveRegion.parent().length, 1, "liveRegion must have a parent" ); +}); + test( ".replaceWith() (#9172)", function() { expect( 1 ); diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index d1a3c252d..2b803b62f 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -294,7 +294,7 @@ $.widget( "ui.autocomplete", { "aria-live": "polite" }) .addClass( "ui-helper-hidden-accessible" ) - .insertBefore( this.element ); + .appendTo( this.document[ 0 ].body ); // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete -- 2.39.5