Fixed #59 and #67 - Fixed accordion and tabview issues

pull/104/head
mertsincan 2019-10-18 09:24:14 +03:00
parent 41fab82296
commit dd62e7f58c
4 changed files with 22 additions and 9 deletions

View File

@ -44,11 +44,11 @@ export default {
},
data() {
return {
tabs: []
d_children: []
};
},
mounted() {
this.tabs = this.$children.filter(child => child.$options._componentTag.indexOf('AccordionTab')===0);
this.d_children = this.$children;
},
methods: {
onTabClick(event, tab) {
@ -76,6 +76,11 @@ export default {
return this.props.multiple ? (this.d_activeTabIndex && this.d_activeTabIndex.indexOf(index) >= 0) : this.d_activeTabIndex === index;
}
},
computed: {
tabs() {
return this.d_children.filter(child => child.$vnode.tag.indexOf('accordiontab') !== -1);
}
},
components: {
'AccordionTabSlot': AccordionTabSlot
}

View File

@ -1,5 +1,6 @@
<script>
export default {
name: 'accordiontab',
props: {
header: null,
active: Boolean,

View File

@ -6,6 +6,7 @@
<script>
export default {
name: 'tabpanel',
props: {
header: null,
active: Boolean,

View File

@ -31,16 +31,11 @@ const TabPanelHeaderSlot = {
export default {
data() {
return {
tabs: []
d_children: []
};
},
mounted() {
this.tabs = this.$children;
let activeTab = this.findActiveTab();
if (!activeTab && this.tabs.length) {
this.tabs[0].d_active = true;
}
this.d_children = this.$children;
},
methods: {
onTabClick(event, tab) {
@ -78,6 +73,17 @@ export default {
return activeTab;
}
},
updated() {
let activeTab = this.findActiveTab();
if (!activeTab && this.tabs.length) {
this.tabs[0].d_active = true;
}
},
computed: {
tabs() {
return this.d_children.filter(child => child.$vnode.tag.indexOf('tabpanel') !== -1);
}
},
components: {
'TabPanelHeaderSlot': TabPanelHeaderSlot
}