0
0
Fork 0

fix(VnSelect): hotFix handleKeyDown add next focus

This commit is contained in:
Alex Moreno 2024-12-10 07:49:59 +01:00
parent 051482fd23
commit dd33dfc766
1 changed files with 12 additions and 1 deletions

View File

@ -268,7 +268,7 @@ async function onScroll({ to, direction, from, index }) {
defineExpose({ opts: myOptions }); defineExpose({ opts: myOptions });
function handleKeyDown(event) { function handleKeyDown(event) {
if (event.key === 'Tab') { if (event.key === 'Tab' && !event.shiftKey) {
event.preventDefault(); event.preventDefault();
const inputValue = vnSelectRef.value?.inputValue; const inputValue = vnSelectRef.value?.inputValue;
@ -286,6 +286,17 @@ function handleKeyDown(event) {
} }
vnSelectRef.value?.hidePopup(); vnSelectRef.value?.hidePopup();
} }
const focusableElements = document.querySelectorAll(
'a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
);
const currentIndex = Array.prototype.indexOf.call(
focusableElements,
event.target
);
if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) {
focusableElements[currentIndex + 1].focus();
}
} }
} }
</script> </script>