Merge branch 'MDL-65102-35' of git://github.com/rezaies/moodle into MOODLE_35_STABLE

This commit is contained in:
David Monllaó
2019-04-23 13:31:05 +02:00
committed by Eloy Lafuente (stronk7)
2 changed files with 16 additions and 3 deletions
File diff suppressed because one or more lines are too long
+15 -2
View File
@@ -696,14 +696,27 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
}
return true;
});
// Support submitting the form without leaving the autocomplete element,
// or submitting too quick before the blur handler action is completed.
inputElement.closest('form').on('submit', function() {
if (options.tags) {
// If tags are enabled, create a tag.
addPendingJSPromise('form-autocomplete-submit')
.resolve(createItem(options, state, originalSelect));
}
return true;
});
inputElement.on('blur', function() {
var pendingPromise = addPendingJSPromise('form-autocomplete-blur');
window.setTimeout(function() {
// Get the current element with focus.
var focusElement = $(document.activeElement);
// Only close the menu if the input hasn't regained focus.
if (focusElement.attr('id') != inputElement.attr('id')) {
// Only close the menu if the input hasn't regained focus, and if the element still exists.
// 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 (options.tags) {
pendingPromise.then(function() {
return createItem(options, state, originalSelect);