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