Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit db19b79

Browse files
committed
Fix shiftTab from index 0 going to -1
1 parent 6a07747 commit db19b79

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ function restrictTabBehavior(event: KeyboardEvent): void {
5656
const currentIndex = elements.indexOf(currentFocus)
5757
if (currentIndex !== -1) {
5858
const newIndex = currentIndex + movement
59-
if (newIndex >= 0) targetIndex = newIndex % elements.length
59+
if (newIndex < 0) {
60+
targetIndex = elements.length - 1
61+
} else {
62+
targetIndex = newIndex % elements.length
63+
}
6064
}
6165
}
6266

0 commit comments

Comments
 (0)