+ type="text"
+ :value="selectedValue"
+ autocomplete="off"
+ @click="onFocus"
+ />
+
-
-
- (query = e.target.value)"
- autocomplete="off"
- placeholder="Search"
- />
-
-
-
-
-
+
@@ -117,7 +99,7 @@ import {
ComboboxOption,
ComboboxButton,
} from '@headlessui/vue'
-import { ref, computed, useAttrs, useSlots, watch } from 'vue'
+import { ref, computed, useAttrs, useSlots, watch, nextTick } from 'vue'
import { ChevronDown, X } from 'lucide-vue-next'
import { watchDebounced } from '@vueuse/core'
@@ -157,18 +139,17 @@ const props = defineProps({
})
const emit = defineEmits(['update:modelValue', 'update:query', 'change'])
-
+const trigger = ref(null)
+const search = ref(null)
const attrs = useAttrs()
const slots = useSlots()
const selectedValue = ref(props.modelValue)
const query = ref('')
-
const valuePropPassed = computed(() => 'value' in attrs)
watch(selectedValue, (val) => {
- if (!val?.value) return
query.value = ''
- console.log('Selected value changed:', val)
+ console.log(val)
emit(valuePropPassed.value ? 'change' : 'update:modelValue', val)
})
@@ -202,18 +183,6 @@ function filterOptions(options) {
)
}
-function displayValue(option) {
- if (!option) return ''
-
- if (typeof option === 'string') {
- const flat = groups.value.flatMap((g) => g.items)
- const match = flat.find((o) => o.value === option)
- return match?.label || option
- }
-
- return option.label
-}
-
watchDebounced(
query,
(val) => {
@@ -222,6 +191,18 @@ watchDebounced(
{ debounce: 300 }
)
+const onFocus = () => {
+ trigger.value?.$el.click()
+ nextTick(() => {
+ search.value?.focus()
+ })
+}
+
+const close = () => {
+ selectedValue.value = null
+ trigger.value?.$el.click()
+}
+
const textColor = computed(() =>
props.disabled ? 'text-ink-gray-5' : 'text-ink-gray-8'
)
diff --git a/frontend/src/components/Controls/Link.vue b/frontend/src/components/Controls/Link.vue
index 91175399..a84cea4f 100644
--- a/frontend/src/components/Controls/Link.vue
+++ b/frontend/src/components/Controls/Link.vue
@@ -94,10 +94,8 @@ const valuePropPassed = computed(() => 'value' in attrs)
const value = computed({
get: () => (valuePropPassed.value ? attrs.value : props.modelValue),
set: (val) => {
- console.log('Setting value to:', val)
return (
- val?.value &&
- emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
+ val && emit(valuePropPassed.value ? 'change' : 'update:modelValue', val)
)
},
})