changed show logic

This commit is contained in:
Mamalizz
2025-03-13 01:35:00 +03:30
parent 26c17ab849
commit 0d336d549a
+8 -14
View File
@@ -26,27 +26,21 @@ const emit = defineEmits<Emits>();
// computed
const isShow = ref(modelValue.value);
watch(
() => isShow.value,
(nv) => {
if (!nv) {
emit("update:modelValue", false);
const isShow = computed({
get: () => modelValue.value ?? false,
set: (value) => {
emit("update:modelValue", value);
if (!value) {
emit("close", null);
}
}
);
},
});
</script>
<template>
<DialogRoot
v-model:open="isShow"
@update:open="
(state) => {
!state ? (isShow = false) : null;
}
"
@update:open="(state) => (isShow = state)"
>
<DialogTrigger :class="!$slots['trigger'] ? 'hidden' : ''">
<slot name="trigger" />