Skip to content

Commit

Permalink
Fixed #59 and #67 - Fixed accordion and tabview issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 18, 2019
1 parent 41fab82 commit dd62e7f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/components/accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/components/accordiontab/AccordionTab.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
export default {
name: 'accordiontab',
props: {
header: null,
active: Boolean,
Expand Down
1 change: 1 addition & 0 deletions src/components/tabpanel/TabPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<script>
export default {
name: 'tabpanel',
props: {
header: null,
active: Boolean,
Expand Down
20 changes: 13 additions & 7 deletions src/components/tabview/TabView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit dd62e7f

Please sign in to comment.