Merge branch 'MDL-68196-master' of git://github.com/rezaies/moodle

This commit is contained in:
Adrian Greeve 2020-04-16 10:55:11 +08:00
commit 50dbf7e9c8
3 changed files with 17 additions and 3 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

@ -834,6 +834,12 @@ function($, log, str, templates, notification, LoadingIcon) {
});
// Whenever the input field changes, update the suggestion list.
if (options.showSuggestions) {
// Store the value of the field as its last value, when the field gains focus.
inputElement.on('focus', function(e) {
var query = $(e.currentTarget).val();
$(e.currentTarget).data('last-value', query);
});
// If this field uses ajax, set it up.
if (options.ajax) {
require([options.ajax], function(ajaxHandler) {
@ -893,7 +899,15 @@ function($, log, str, templates, notification, LoadingIcon) {
};
// Trigger an ajax update after the text field value changes.
inputElement.on("input", throttledHandler);
inputElement.on('input', function(e) {
var query = $(e.currentTarget).val();
var last = $(e.currentTarget).data('last-value');
// IE11 fires many more input events than required - even when the value has not changed.
if (last !== query) {
throttledHandler(e);
}
$(e.currentTarget).data('last-value', query);
});
});
} else {
inputElement.on('input', function(e) {