Skip to content

Commit

Permalink
Merge pull request #640 from ntedgi/accordion-does-not-support-dynami…
Browse files Browse the repository at this point in the history
…c-tabs-622

Fix issue : Accordion does not support dynamic tabs #622
  • Loading branch information
cagataycivici authored Nov 25, 2020
2 parents 9898274 + 2a39a97 commit d81c42e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,24 @@ export default {
getHeaderIcon(i) {
const active = this.isTabActive(i);
return ['p-accordion-toggle-icon pi', {'pi-chevron-right': !active, 'pi-chevron-down': active}];
},
childIsAccordionTab(child) {
return child.type.name === 'accordiontab'
}
},
computed: {
tabs() {
return this.$slots.default().filter(child => child.type.name === 'accordiontab');
const tabs = []
this.$slots.default().forEach(child => {
if (this.childIsAccordionTab(child)) tabs.push(child)
else if (child.children.length > 0)
child.children.forEach(nestedChild => {
if (this.childIsAccordionTab(nestedChild)) tabs.push(nestedChild)
})
}
)
return tabs
},
ariaId() {
return UniqueComponentId();
Expand All @@ -128,4 +141,4 @@ export default {
.p-accordion-header-text {
line-height: 1;
}
</style>
</style>

0 comments on commit d81c42e

Please sign in to comment.