From a61f386e13860fb2f1f6bd4dcc6ef24882d785e2 Mon Sep 17 00:00:00 2001
From: Konrad Mohrfeldt <km@roko.li>
Date: Thu, 30 May 2024 18:13:30 +0200
Subject: [PATCH] fix: reset activeIndex after choices have been updated

---
 src/components/ComboBox.vue | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/components/ComboBox.vue b/src/components/ComboBox.vue
index dec36ed7..c75f0f4f 100644
--- a/src/components/ComboBox.vue
+++ b/src/components/ComboBox.vue
@@ -225,6 +225,13 @@ watchEffect(() => {
   activeIndex.value = clamp(activeIndex.value, 0, lastChoiceIndex.value)
 })
 
+watch(
+  () => props.choices,
+  () => {
+    activeIndex.value = 0
+  },
+)
+
 watch(hasFocus, (hasFocus, hadFocus) => {
   if (hasFocus && !hadFocus) {
     open()
-- 
GitLab