MDL-68167 lib: autocomplete focos should not be removed on blur

See https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/listbox-rearrangeable.html
This commit is contained in:
Shamim Rezaie
2020-10-30 16:08:56 +11:00
parent 352e2f7787
commit 4d00ebae7a
3 changed files with 10 additions and 13 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8 -11
View File
@@ -812,17 +812,14 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
// Remove it from the selection.
pendingPromise.resolve(deselectItem(options, state, $(e.currentTarget), originalSelect));
});
// Remove the highlight of items when user tabs out the tag list.
selectionElement.on('blur', function(e) {
e.preventDefault();
$(this).children().attr('data-active-selection', false).attr('id', '');
});
// When tag list is focused, highlight the first item.
selectionElement.on('focus', function(e) {
e.preventDefault();
var element = $(this).children('[data-active-selection=true]');
if (element && element.length === 0) {
activateNextSelection(state);
// When listbox is focused, focus on the first option if there is no focused option.
selectionElement.on('focus', function() {
// Find the list of selections.
var selectionsElement = $(document.getElementById(state.selectionId));
// Find the active one.
var element = selectionsElement.children('[data-active-selection=true]');
if (!element.length) {
return activateSelection(0, state);
}
});
// Keyboard navigation for the selection list.