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

9 lines
260 B
JavaScript
Raw Normal View History

2021-12-20 03:25:43 +00:00
$(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();
}
});