mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
fix broken tabs
This commit is contained in:
@@ -124,7 +124,7 @@ export default class SlTabGroup extends LitElement {
|
||||
return [...(slot.assignedElements() as SlTab[])].filter(el => {
|
||||
return includeDisabled
|
||||
? el.tagName.toLowerCase() === 'sl-tab'
|
||||
: el.tagName.toLowerCase() === 'sl-tab' && el.disabled;
|
||||
: el.tagName.toLowerCase() === 'sl-tab' && !el.disabled;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -232,24 +232,20 @@ export default class SlTabGroup extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
setActiveTab(tab: SlTab | undefined, options?: { emitEvents?: boolean; scrollBehavior?: 'auto' | 'smooth' }) {
|
||||
setActiveTab(tab: SlTab, options?: { emitEvents?: boolean; scrollBehavior?: 'auto' | 'smooth' }) {
|
||||
options = {
|
||||
emitEvents: true,
|
||||
scrollBehavior: 'auto',
|
||||
...options
|
||||
};
|
||||
|
||||
if (tab && tab !== this.activeTab && !tab.disabled) {
|
||||
if (tab !== this.activeTab && !tab.disabled) {
|
||||
const previousTab = this.activeTab;
|
||||
this.activeTab = tab;
|
||||
|
||||
// Sync active tab and panel
|
||||
this.tabs.forEach(el => {
|
||||
el.active = el === this.activeTab;
|
||||
});
|
||||
this.panels.forEach(el => {
|
||||
el.active = el.name === tab.panel;
|
||||
});
|
||||
this.tabs.map(el => (el.active = el === this.activeTab));
|
||||
this.panels.map(el => (el.active = el.name === this.activeTab?.panel));
|
||||
this.syncIndicator();
|
||||
|
||||
if (['top', 'bottom'].includes(this.placement)) {
|
||||
@@ -257,10 +253,11 @@ export default class SlTabGroup extends LitElement {
|
||||
}
|
||||
|
||||
// Emit events
|
||||
if (options.emitEvents === true) {
|
||||
if (options.emitEvents) {
|
||||
if (previousTab) {
|
||||
emit(this, 'sl-tab-hide', { detail: { name: previousTab.panel } });
|
||||
}
|
||||
|
||||
emit(this, 'sl-tab-show', { detail: { name: this.activeTab.panel } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user