forked from verdnatura/salix-front
fix(VnSelect): hotFix handleKeyDown add next focus
This commit is contained in:
parent
051482fd23
commit
dd33dfc766
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue