changed combobox logic
This commit is contained in:
@@ -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;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user