From e5c9562a0a3af741aac1c60496adf3781a23c9d9 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Thu, 23 May 2019 16:28:09 +0300 Subject: [PATCH] Add two-way binding support to Accordion --- src/components/accordion/Accordion.vue | 6 ++++-- src/views/accordion/AccordionDemo.vue | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/accordion/Accordion.vue b/src/components/accordion/Accordion.vue index 156012a51..0f6982714 100644 --- a/src/components/accordion/Accordion.vue +++ b/src/components/accordion/Accordion.vue @@ -18,8 +18,10 @@ export default { this.tabs.forEach(tab => tab.d_active = false); } - tab.d_active = !tab.d_active; - let eventName = !tab.active ? 'tab-close' : 'tab-open'; + const newActiveState = !tab.d_active; + tab.d_active = newActiveState; + tab.$emit('update:active', newActiveState); + let eventName = newActiveState ? 'tab-open' : 'tab-close'; this.$emit(eventName, { originalEvent: event, tab: tab diff --git a/src/views/accordion/AccordionDemo.vue b/src/views/accordion/AccordionDemo.vue index d572c8549..7430893d6 100644 --- a/src/views/accordion/AccordionDemo.vue +++ b/src/views/accordion/AccordionDemo.vue @@ -54,7 +54,7 @@