clrghouz/public/plugin/select2/fix-autofocus.js

9 lines
260 B
JavaScript
Raw Permalink Normal View History

$(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();
}
});