aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorDylan Barrell <dylan@barrell.com>2013-12-22 11:36:43 -0500
committerJörn Zaefferer <joern.zaefferer@gmail.com>2014-01-14 11:09:49 +0100
commit0b28d597fe1857590c9719c8b41f00e77967f7d7 (patch)
tree0cb11a3b5469af8222729742926726e30a25a9a5 /ui/jquery.ui.autocomplete.js
parent6ec452cc63313ec03f58942ce896036c7a2fcf3f (diff)
downloadjquery-ui-0b28d597fe1857590c9719c8b41f00e77967f7d7.tar.gz
jquery-ui-0b28d597fe1857590c9719c8b41f00e77967f7d7.zip
Autocomplete: Announce autocomplete correctly in all ATs.
Fixes #9631 Closes gh-1153
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index f5dea64de..77024afa0 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -230,6 +230,7 @@ $.widget( "ui.autocomplete", {
}
},
menufocus: function( event, ui ) {
+ var label, item;
// support: Firefox
// Prevent accidental activation of menu items in Firefox (#7024 #9118)
if ( this.isNewMenu ) {
@@ -245,19 +246,19 @@ $.widget( "ui.autocomplete", {
}
}
- var item = ui.item.data( "ui-autocomplete-item" );
+ item = ui.item.data( "ui-autocomplete-item" );
if ( false !== this._trigger( "focus", event, { item: item } ) ) {
// use value to match what will end up in the input, if it was a key event
if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
this._value( item.value );
}
- } else {
- // Normally the input is populated with the item's value as the
- // menu is navigated, causing screen readers to notice a change and
- // announce the item. Since the focus event was canceled, this doesn't
- // happen, so we update the live region so that screen readers can
- // still notice the change and announce it.
- this.liveRegion.text( item.value );
+ }
+
+ // Announce the value in the liveRegion
+ label = ui.item.attr( "aria-label" ) || item.value;
+ if ( label && jQuery.trim( label ).length ) {
+ this.liveRegion.children().hide();
+ $( "<div>" ).text( label ).appendTo( this.liveRegion );
}
},
menuselect: function( event, ui ) {
@@ -291,7 +292,8 @@ $.widget( "ui.autocomplete", {
this.liveRegion = $( "<span>", {
role: "status",
- "aria-live": "polite"
+ "aria-live": "assertive",
+ "aria-relevant": "additions"
})
.addClass( "ui-helper-hidden-accessible" )
.appendTo( this.document[ 0 ].body );
@@ -595,7 +597,8 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, {
} else {
message = this.options.messages.noResults;
}
- this.liveRegion.text( message );
+ this.liveRegion.children().hide();
+ $( "<div>" ).text( message ).appendTo( this.liveRegion );
}
});