changed combobox logic

This commit is contained in:
Mamalizz
2025-06-04 19:11:11 +03:30
parent 29b2a98339
commit 5373db57bd
+5 -2
View File
@@ -33,7 +33,7 @@ const emit = defineEmits(["update:modelValue"]);
// state // state
const value = ref<OptionChildren>(); const value = ref<OptionChildren | Option>();
// watch // watch
@@ -49,7 +49,10 @@ watch(
watch( watch(
() => modelValue.value, () => modelValue.value,
(newValue) => { (newValue) => {
const target = options.value.flatMap((option) => option.children).find((child) => child.id == newValue); let target;
target = newValue?.toString().startsWith("category")
? options.value.find((child) => child.slug == newValue)
: options.value.flatMap((option) => option.children).find((child) => child.slug == newValue);
value.value = target || undefined; value.value = target || undefined;
}, },