Skip to content
Permalink
Browse files

MDL-59527 forms: Race cond with ajax autocomplete

Sometimes (rarely) the auto complete will show "No suggestions" when there are valid suggestions.
  • Loading branch information...
damyon committed Jul 13, 2017
1 parent 7624f86 commit 69f7abf28b7125055cb5eabd03da245c4cbac19b
Showing with 12 additions and 5 deletions.
  1. +1 −1 lib/amd/build/form-autocomplete.min.js
  2. +11 −4 lib/amd/src/form-autocomplete.js

Some generated files are not rendered by default. Learn more.

@@ -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);
}
});
}

0 comments on commit 69f7abf

Please sign in to comment.
You can’t perform that action at this time.