MDL-75669 theme_boost: Fix formautocomplete inside dropdowns
Fix problem where having a dropdown with a form autocomplete inside and pressing Escape key will close the hole dropdown instead only the autocomplete suggestions.
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -227,6 +227,23 @@ const dropdownFix = () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent closing the dropdown when the autocomplete suggestions are visible.
|
||||
document.addEventListener('hide.bs.dropdown', (e) => {
|
||||
const dropdown = e.target.closest('.dropdown');
|
||||
if (!dropdown) {
|
||||
return;
|
||||
}
|
||||
const autocompleteSuggestions = document.querySelector('.form-autocomplete-suggestions:not([aria-hidden="true"])');
|
||||
if (autocompleteSuggestions) {
|
||||
// Dropdown should not be hidden while the autocomplete suggestions are visible inside.
|
||||
e.preventDefault();
|
||||
// Return the focus to the autocomplete input.
|
||||
const autocompleteElement = autocompleteSuggestions.closest('[data-fieldtype="autocomplete"]');
|
||||
const autocompleteInput = autocompleteElement.querySelector('.form-autocomplete-input input');
|
||||
setTimeout(()=> autocompleteInput.focus(), 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user