Skip to content

Commit

Permalink
fix(components): prevent postChange event emitting before post-tabs l…
Browse files Browse the repository at this point in the history
…oads (#3247)
  • Loading branch information
alizedebray authored Jul 18, 2024
1 parent 9a88173 commit 2a03757
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
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

0 comments on commit 2a03757

Please sign in to comment.