Index: theme/bootstrapbase/style/moodle.css IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- theme/bootstrapbase/style/moodle.css (revision d509f80c48f4ef49a03ab8396eec869bc7563882) +++ theme/bootstrapbase/style/moodle.css (revision ) @@ -16900,7 +16900,7 @@ margin: 0.2em; min-height: 21px; } -.form-autocomplete-multiple [role=listitem] { +.form-autocomplete-multiple [role=listitem], .form-autocomplete-single [role=listitem] { cursor: pointer; } .form-autocomplete-suggestions { Index: lib/amd/src/form-autocomplete.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lib/amd/src/form-autocomplete.js (revision d509f80c48f4ef49a03ab8396eec869bc7563882) +++ lib/amd/src/form-autocomplete.js (revision ) @@ -89,7 +89,7 @@ activeValue = $(document.getElementById(activeId)).attr('data-value'); } originalSelect.children('option').each(function(index, ele) { - if ($(ele).prop('selected')) { + if ($(ele).prop('selected') && $(ele).attr('value')) { items.push({label: $(ele).html(), value: $(ele).attr('value')}); } }); @@ -135,20 +135,27 @@ */ var deselectItem = function(options, state, item, originalSelect) { var selectedItemValue = $(item).attr('data-value'); + var emptyoption = false; - // We can only deselect items if this is a multi-select field. - if (options.multiple) { - // Look for a match, and toggle the selected property if there is a match. - originalSelect.children('option').each(function(index, ele) { - if ($(ele).attr('value') == selectedItemValue) { - $(ele).prop('selected', false); - // We remove newly created custom tags from the suggestions list when they are deselected. - if ($(ele).attr('data-iscustom')) { - $(ele).remove(); - } + originalSelect.children('option').each(function (index, ele) { + if ($(ele).attr('value') == selectedItemValue && options.multiple) { + $(ele).prop('selected', false); + // We remove newly created custom tags from the suggestions list when they are deselected. + if ($(ele).attr('data-iscustom')) { + $(ele).remove(); + } + } else if (!options.multiple) { + $(ele).prop('selected', false); + if (!$(ele).attr('value')) { + emptyoption = true; } - }); + } + }); + + if (!emptyoption) { + originalSelect.prepend($('