MDL-59366 core_amd: Modifications for form-autocomplete
* New optional parameter 'closeSuggestionsOnSelect' for the enhance() function for form-autocomplete. Setting this to true will close the suggestions popup immediately after an option has been selected. If not specified, it defaults to true for single-select elements and false for multiple-select elements. Part of MDL-59290.
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -451,7 +451,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
// Notifiy that the selection changed.
|
||||
notifyChange(originalSelect);
|
||||
|
||||
if (!options.multiple) {
|
||||
if (options.closeSuggestionsOnSelect) {
|
||||
// Clear the input element.
|
||||
inputElement.val('');
|
||||
// Close the list of suggestions.
|
||||
@@ -718,9 +718,11 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
* @param {Boolean} caseSensitive - If search has to be made case sensitive.
|
||||
* @param {Boolean} showSuggestions - If suggestions should be shown
|
||||
* @param {String} noSelectionString - Text to display when there is no selection
|
||||
* @param {Boolean} closeSuggestionsOnSelect - Whether to close the suggestions immediately after making a selection.
|
||||
* @return {Promise}
|
||||
*/
|
||||
enhance: function(selector, tags, ajax, placeholder, caseSensitive, showSuggestions, noSelectionString) {
|
||||
enhance: function(selector, tags, ajax, placeholder, caseSensitive, showSuggestions, noSelectionString,
|
||||
closeSuggestionsOnSelect) {
|
||||
// Set some default values.
|
||||
var options = {
|
||||
selector: selector,
|
||||
@@ -769,6 +771,13 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
};
|
||||
options.multiple = originalSelect.attr('multiple');
|
||||
|
||||
if (typeof closeSuggestionsOnSelect !== "undefined") {
|
||||
options.closeSuggestionsOnSelect = closeSuggestionsOnSelect;
|
||||
} else {
|
||||
// If not specified, this will close suggestions by default for single-select elements only.
|
||||
options.closeSuggestionsOnSelect = !options.multiple;
|
||||
}
|
||||
|
||||
var originalLabel = $('[for=' + state.selectId + ']');
|
||||
// Create the new markup and insert it after the select.
|
||||
var suggestions = [];
|
||||
|
||||
@@ -38,6 +38,9 @@ information provided here is intended especially for developers.
|
||||
- get_enrolled_with_capabilities_join()
|
||||
Setting this parameter to a non-zero value will add a condition to the query such that only users that were enrolled
|
||||
with this enrolment method will be returned.
|
||||
* New optional parameter 'closeSuggestionsOnSelect' for the enhance() function for form-autocomplete. Setting this to true will
|
||||
close the suggestions popup immediately after an option has been selected. If not specified, it defaults to true for single-select
|
||||
elements and false for multiple-select elements.
|
||||
|
||||
=== 3.3.1 ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user