MDL-66312 js: Autocomplete promises were inside out
The pending promise should nott be resolved until the changes are complete. Previously the resolution of the pendingPromise was triggering the other changes.
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -712,6 +712,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
window.setTimeout(function() {
|
||||
// Get the current element with focus.
|
||||
var focusElement = $(document.activeElement);
|
||||
var timeoutPromise = $.Deferred();
|
||||
|
||||
// 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.
|
||||
@@ -721,18 +722,22 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
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() {
|
||||
timeoutPromise.then(function() {
|
||||
return createItem(options, state, originalSelect);
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
pendingPromise.then(function() {
|
||||
timeoutPromise.then(function() {
|
||||
return closeSuggestions(state);
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
|
||||
pendingPromise.resolve();
|
||||
timeoutPromise.then(function() {
|
||||
return pendingPromise.resolve();
|
||||
})
|
||||
.catch();
|
||||
timeoutPromise.resolve();
|
||||
}, 500);
|
||||
});
|
||||
if (options.showSuggestions) {
|
||||
|
||||
Reference in New Issue
Block a user