Skip to content

Commit 63d5d59

Browse files
bteashuuji3
andauthored
feat: allows keyboard navigation to switch from last to first (#1543)
Co-authored-by: TAKAHASHI Shuuji <id@shuuji3.xyz>
1 parent d51b574 commit 63d5d59

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/components/Compare/PackageSelector.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,20 @@ function handleKeydown(e: KeyboardEvent) {
105105
case 'ArrowDown':
106106
e.preventDefault()
107107
if (count === 0) return
108-
highlightedIndex.value = Math.min(highlightedIndex.value + 1, count - 1)
108+
if (highlightedIndex.value < count - 1) {
109+
highlightedIndex.value++
110+
} else {
111+
highlightedIndex.value = 0
112+
}
109113
break
110114
111115
case 'ArrowUp':
112116
e.preventDefault()
113117
if (count === 0) return
114118
if (highlightedIndex.value > 0) {
115119
highlightedIndex.value--
120+
} else {
121+
highlightedIndex.value = count - 1
116122
}
117123
break
118124

0 commit comments

Comments
 (0)