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(components): prevent postChange event emitting before post-tabs loads #3247

Merged
Merged
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/fifty-peaches-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Prevent the `post-tabs` component from triggering a `post Change` event before it is loaded.
14 changes: 4 additions & 10 deletions packages/components/src/components/post-tabs/post-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,17 @@ export class PostTabs {
}

// hide the currently visible panel only if no other animation is running
if (previousTab && !this.showing && !this.hiding) {
this.hidePanel(previousTab.panel);
}
if (previousTab && !this.showing && !this.hiding) this.hidePanel(previousTab.panel);

// wait for any hiding animation to complete before showing the selected tab
if (this.hiding) {
await this.hiding.finished;
}
if (this.hiding) await this.hiding.finished;

this.showSelectedPanel();

// wait for any display animation to complete for the returned promise to fully resolve
if (this.showing) {
await this.showing.finished;
}
if (this.showing) await this.showing.finished;

this.postChange.emit(this.activeTab.panel);
if (this.isLoaded) this.postChange.emit(this.activeTab.panel);
}

private moveMisplacedTabs() {
Expand Down