osb/public/plugin/select2/fix-autofocus.js
2022-02-01 16:45:35 +11:00

9 lines
260 B
JavaScript
Vendored

$(document).on('select2:open',(event) => {
const searchField = document.querySelector(
`.select2-search__field[aria-controls="select2-${event.target.getAttribute('data-select2-id')}-results"]`,
);
if (searchField) {
searchField.focus();
}
});