jquery/jquery-ui — pull request #652 by jzaefferer (2012-05-09 17:40:03+00:00)
Title: Autocomplete aria

Starting this pull request to coordinate work between Everett, Hans, Scott and me (could also close this and put it on the wiki, though we should have more code soon). I've just spend a good amount of time reviewing the yahoo.com autocomplete, which is actually pretty similar to our approach. We figured that announcing only "autocomplete popup" is not useful. To make the announcements useful, it should be close to what yahoo.com is doing: "No search results available" or "x search results available, use up and down cursors to navigate". They don't set aria-activedescendent, so navigation gets announced properly as the input's value changes.

Here's a suggestion what the message format could look like:

```js
var defaults = {
messages: {
noresults: "No search results",
xresults: "$1 results available"
xresults: function(amount) {
return amount + " result" + (amount > 1 ? "s" : "") + " available, use up/down cursor...";
}
}
}

var de = {
messages: {
noresults: "Nichts gefunden",
xresults: function(amount) {
return amount + " Ergebnisse...";
}
}
}

xresults.replace("$1", amount)
```

If its a string, interpolate, if its a function, call it with all variables. That way we can allow simple interpolation where that's enough, and make it flexible enough to deal with more complex cases. Once Globalize adds support for this (https://github.com/jquery/globalize/issues/100), we can rip out the little custom code we'd require here and use Globalize instead.

The other change we should make is to extend menu to allow control over aria attributes. For autocomplete, we don't actually want any of them (see the yahoo.com example), just an unoredered list. For Selectmenu, we want listbox and role option on the items.