I have a select2 dropdown with a search box. Currently, when tabbing and hitting ENTER, the focus is on search box which is the default behavior in select2.
It currently looks like this and the focus is on the search box after the dropdown is opened :
Image Link
However, when I press the TAB key after the dropdown opens, I want to focus on the first option in the search results list. I have this code for listening TAB key on the page, but it only doesn’t listen for “select2-results__option” even if I put tabindex = 0 into the option tag. Is it possible to achieve this ? I need to select the first “select2-results__option” after pressing the KEY tab.
$(document).on('keyup', '.secondary-overlay-trigger', e => {
e.stopPropagation();
if (e.keyCode === KEY_TAB) {
$('#root, #wrapper, .cel-Faq, .checkout-login-page').addClass('cel-container--has-focus');
}
});
Thanks !