back port fix from issue #24429

This commit is contained in:
Florian HENRY
2023-09-13 13:25:44 +02:00
parent 97dde30c16
commit 814f95c5e7

View File

@@ -1302,14 +1302,14 @@ $(document).ready(function() {
<?php
if (empty($conf->global->MAIN_DISABLE_SELECT2_FOCUS_PROTECTION) && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) {
?>
$(document).on('select2:open', () => {
$(document).on('select2:open', (e) => {
console.log("Execute the focus (click on combo or use space when on component");
let allFound = document.querySelectorAll('.select2-container--open .select2-search__field');
$(this).one('mouseup keyup',()=>{
setTimeout(()=>{
allFound[allFound.length - 1].focus();
},0);
});
const target = $(e.target);
if (target && target.length) {
let id = target[0].id || target[0].name;
if (id.substr(-2) == "[]") id = id.substr(0,id.length-2);
document.querySelector('input[aria-controls*='+id+']').focus();
}
});
<?php
}