diff --git a/.changeset/fifty-peaches-turn.md b/.changeset/fifty-peaches-turn.md new file mode 100644 index 0000000000..4217acc96a --- /dev/null +++ b/.changeset/fifty-peaches-turn.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-components': patch +--- + +Prevent the `post-tabs` component from triggering a `post Change` event before it is loaded. diff --git a/packages/components/src/components/post-tabs/post-tabs.tsx b/packages/components/src/components/post-tabs/post-tabs.tsx index 68d6e97e9a..b6d6d03510 100644 --- a/packages/components/src/components/post-tabs/post-tabs.tsx +++ b/packages/components/src/components/post-tabs/post-tabs.tsx @@ -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() {