Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(component): fix tab isolation in nested post-tabs component (cherry pick #4211 to v8) #4214

Open
wants to merge 3 commits into
base: release/v8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gorgeous-glasses-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Fix tab isolation in nested `post-tabs` components by scoping tab queries and interactions to the current instance.
10 changes: 5 additions & 5 deletions packages/components/src/components/post-tabs/post-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class PostTabs {
private hiding: Animation;
private isLoaded = false;

private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {
return this.host.querySelectorAll('post-tab-header');
}
private get tabs(): HTMLPostTabHeaderElement[] {
return Array.from(this.host.querySelectorAll(':scope > post-tab-header'));
}

@Element() host: HTMLPostTabsElement;

Expand All @@ -45,7 +45,7 @@ export class PostTabs {
this.moveMisplacedTabs();
this.enableTabs();

const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
const initiallyActivePanel = this.activePanel || this.tabs[0]?.panel;
void this.show(initiallyActivePanel);

this.isLoaded = true;
Expand Down Expand Up @@ -128,7 +128,7 @@ export class PostTabs {

// if the currently active tab was removed from the DOM then select the first one
if (this.activeTab && !this.activeTab.isConnected) {
void this.show(this.tabs.item(0).panel);
void this.show(this.tabs[0]?.panel);
}
}

Expand Down
Loading