Skip to content

Commit 7b9c810

Browse files
committed
Autocomplete: Append liveRegion to body to support detached init. Fixes #9590 - Dynamically adding input field breaks auto-complete's accessibility for screen readers
1 parent b99f825 commit 7b9c810

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tests/unit/autocomplete/autocomplete_core.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ test( "ARIA", function() {
257257
"Live region for multiple values" );
258258
});
259259

260+
test( "ARIA, init on detached input", function() {
261+
expect( 1 );
262+
var element = $( "<input>" ).autocomplete({
263+
source: [ "java", "javascript" ]
264+
}),
265+
liveRegion = element.autocomplete( "instance" ).liveRegion;
266+
equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
267+
});
268+
260269
test( ".replaceWith() (#9172)", function() {
261270
expect( 1 );
262271

ui/jquery.ui.autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ $.widget( "ui.autocomplete", {
294294
"aria-live": "polite"
295295
})
296296
.addClass( "ui-helper-hidden-accessible" )
297-
.insertBefore( this.element );
297+
.appendTo( this.document[ 0 ].body );
298298

299299
// turning off autocomplete prevents the browser from remembering the
300300
// value when navigating through history, so we re-enable autocomplete

0 commit comments

Comments
 (0)