Skip to content

Commit 32b0117

Browse files
committed
fix incorrect activeIndex when handling Focus.Previous
This is already available in the React version, now let's sync it in the Vue version as well.
1 parent c6b5a81 commit 32b0117

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/@headlessui-vue/src/utils/calculate-active-index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export function calculateActiveIndex<TItem>(
4848
}
4949

5050
case Focus.Previous: {
51+
// If nothing is active, focus the last relevant item
52+
if (activeIndex === -1) activeIndex = items.length
53+
5154
for (let i = activeIndex - 1; i >= 0; --i) {
5255
if (!resolvers.resolveDisabled(items[i], i, items)) {
5356
return i

0 commit comments

Comments
 (0)