This repository was archived by the owner on Sep 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,20 +50,21 @@ function restrictTabBehavior(event: KeyboardEvent): void {
5050
5151 const movement = event.shiftKey ? -1 : 1
5252 const currentFocus = dialog.contains(document.activeElement) ? document.activeElement : null
53- let targetIndex = 0
53+ let targetIndex = movement === -1 ? -1 : 0
5454
5555 if (currentFocus) {
5656 const currentIndex = elements . indexOf ( currentFocus )
5757 if ( currentIndex !== - 1 ) {
58- const newIndex = currentIndex + movement
59- if ( newIndex < 0 ) {
60- targetIndex = elements . length - 1
61- } else {
62- targetIndex = newIndex % elements . length
63- }
58+ targetIndex = currentIndex + movement
6459 }
6560 }
6661
62+ if ( targetIndex < 0 ) {
63+ targetIndex = elements . length - 1
64+ } else {
65+ targetIndex = targetIndex % elements . length
66+ }
67+
6768 elements[targetIndex].focus()
6869}
6970
You can’t perform that action at this time.
0 commit comments