fix(tabs): allow initialization without children
This commit is contained in:
parent
0b5ed48e74
commit
03c294c9ea
3 changed files with 11 additions and 1 deletions
5
.changeset/hip-buses-itch.md
Normal file
5
.changeset/hip-buses-itch.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/tabs': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
tabs: allow to be initialized withhout children
|
||||||
|
|
@ -164,7 +164,7 @@ export class LionTabs extends LitElement {
|
||||||
firstUpdated(changedProperties) {
|
firstUpdated(changedProperties) {
|
||||||
super.firstUpdated(changedProperties);
|
super.firstUpdated(changedProperties);
|
||||||
this.__setupSlots();
|
this.__setupSlots();
|
||||||
if (this.tabs[0].disabled) {
|
if (this.tabs[0]?.disabled) {
|
||||||
this.selectedIndex = this.tabs.findIndex(tab => !tab.disabled);
|
this.selectedIndex = this.tabs.findIndex(tab => !tab.disabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,11 @@ describe('<lion-tabs>', () => {
|
||||||
);
|
);
|
||||||
expect(selectedTab.textContent).to.equal('tab 2');
|
expect(selectedTab.textContent).to.equal('tab 2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can initially be instantiated without children', async () => {
|
||||||
|
const el = /** @type {LionTabs} */ (await fixture(html` <lion-tabs> </lion-tabs> `));
|
||||||
|
expect(el.tabs).to.eql([]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Tabs ([slot=tab])', () => {
|
describe('Tabs ([slot=tab])', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue