MDL-59527 forms: Race cond with ajax autocomplete

Sometimes (rarely) the auto complete will show "No suggestions" when there are valid suggestions.
This commit is contained in:
Damyon Wiese 2017-07-13 16:59:51 +08:00
parent 350700bf8b
commit 47dd535097
2 changed files with 12 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -536,7 +536,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
updateAjax(e, options, state, originalSelect, ajaxHandler);
});
} else {
// Else - open the suggestions list.
// Open the suggestions list.
updateSuggestions(options, state, inputElement.val(), originalSelect);
}
}
@ -613,11 +613,18 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
});
if (options.showSuggestions) {
var arrowElement = $(document.getElementById(state.downArrowId));
arrowElement.on('click', function() {
arrowElement.on('click', function(e) {
// Prevent the close timer, or we will open, then close the suggestions.
inputElement.focus();
// Show the suggestions list.
updateSuggestions(options, state, inputElement.val(), originalSelect);
// Handle ajax population of suggestions.
if (!inputElement.val() && options.ajax) {
require([options.ajax], function(ajaxHandler) {
updateAjax(e, options, state, originalSelect, ajaxHandler);
});
} else {
// Else - open the suggestions list.
updateSuggestions(options, state, inputElement.val(), originalSelect);
}
});
}