From 4ddb99a878777286c5a8728aaa38f0766123f299 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Mon, 21 Jul 2025 16:22:24 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feature:=20emit=20handler=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/accordion/VAccordion.vue | 27 +++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/accordion/VAccordion.vue b/src/components/accordion/VAccordion.vue index 1951812..c130e49 100644 --- a/src/components/accordion/VAccordion.vue +++ b/src/components/accordion/VAccordion.vue @@ -2,14 +2,37 @@ import Accordion from 'primevue/accordion'; import VAccordionChild from './VAccordionChild.vue'; import type IVAccordion from './IVAccordion.type'; +import { ref, watch } from 'vue'; const props = withDefaults(defineProps(), { - value: null, + value: null, +}); + +const emit = defineEmits([ + 'update:value', +]) + +const localValue = ref(props.value); +watch(() => props.value, (newVal) => { + if(localValue.value !== newVal) { + localValue.value = newVal; + } +}); + +watch(localValue, (newVal) => { + if(props.value !== newVal){ + emit('update:value', newVal); + } });