From 5463c8aec08dfa07a01f95646e44a3b4bee070fe Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Fri, 26 Aug 2022 14:50:55 +0300
Subject: optimization for dynamic

---
 src/components/_sila/Global/Collapse.vue | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

(limited to 'src/components/_sila/Global/Collapse.vue')

diff --git a/src/components/_sila/Global/Collapse.vue b/src/components/_sila/Global/Collapse.vue
index 36778571..280e769b 100644
--- a/src/components/_sila/Global/Collapse.vue
+++ b/src/components/_sila/Global/Collapse.vue
@@ -4,13 +4,12 @@
       v-b-toggle="id"
       variant="collapse"
       class="d-flex flex-nowrap justify-content-start"
-      @click="onClick"
     >
       <slot name="image"></slot>
       {{ title }}
       <component :is="iconChevronUp" class="icon-expand" />
     </b-button>
-    <b-collapse :id="id" visible>
+    <b-collapse :id="id" v-model="visible">
       <slot></slot>
     </b-collapse>
   </div>
@@ -29,18 +28,24 @@ export default {
       type: String,
       default: null,
     },
+    opened: {
+      type: Boolean,
+      default: false,
+    },
   },
   data() {
     return {
-      opened: true,
+      visible: false,
       iconChevronUp: iconChevronUp,
     };
   },
-  methods: {
-    onClick() {
-      this.opened = !this.opened;
-      this.$emit('opened', this.opened);
+  watch: {
+    visible() {
+      this.$emit('opened', this.visible);
     },
   },
+  created() {
+    this.visible = this.opened;
+  },
 };
 </script>
-- 
cgit v1.2.3

