MDL-63198 forms: click on scrollbar should not close the suggestions box

This commit is contained in:
Shamim Rezaie 2019-06-16 19:46:04 +10:00
parent f622ee97e3
commit e75bf41538
4 changed files with 8 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -719,10 +719,13 @@ function($, log, str, templates, notification, LoadingIcon) {
// Get the current element with focus.
var focusElement = $(document.activeElement);
// Only close the menu if the input hasn't regained focus, and if the element still exists.
// Only close the menu if the input hasn't regained focus and if the element still exists,
// and regain focus if the scrollbar is clicked.
// Due to the half a second delay, it is possible that the input element no longer exist
// by the time this code is being executed.
if (focusElement.attr('id') != inputElement.attr('id') && $('#' + state.inputId).length) {
if (focusElement.is(document.getElementById(state.suggestionsId))) {
inputElement.focus(); // Probably the scrollbar is clicked. Regain focus.
} else if (!focusElement.is(inputElement) && $(document.getElementById(state.inputId)).length) {
if (options.tags) {
pendingPromise.then(function() {
return createItem(options, state, originalSelect);

View File

@ -35,7 +35,7 @@
{ "label": "Another item label with <strong>tags</strong>", "value": "4" }
]}
}}
<ul class="form-autocomplete-suggestions" id="{{suggestionsId}}" role="listbox" aria-hidden="true">
<ul class="form-autocomplete-suggestions" id="{{suggestionsId}}" role="listbox" aria-hidden="true" tabindex="-1">
{{#options}}
<li role="option" data-value="{{value}}">{{{label}}}</li>
{{/options}}