Merge pull request #640 from ntedgi/accordion-does-not-support-dynamic-tabs-622
Fix issue : Accordion does not support dynamic tabs #622pull/682/head
commit
d81c42ed9b
|
@ -98,11 +98,24 @@ export default {
|
||||||
getHeaderIcon(i) {
|
getHeaderIcon(i) {
|
||||||
const active = this.isTabActive(i);
|
const active = this.isTabActive(i);
|
||||||
return ['p-accordion-toggle-icon pi', {'pi-chevron-right': !active, 'pi-chevron-down': active}];
|
return ['p-accordion-toggle-icon pi', {'pi-chevron-right': !active, 'pi-chevron-down': active}];
|
||||||
|
},
|
||||||
|
childIsAccordionTab(child) {
|
||||||
|
return child.type.name === 'accordiontab'
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
tabs() {
|
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() {
|
ariaId() {
|
||||||
return UniqueComponentId();
|
return UniqueComponentId();
|
||||||
|
|
Loading…
Reference in New Issue