From 96932b37e11d93ae1bda36b9ac1a41ffb71893f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9=20Debray?= Date: Wed, 10 Jul 2024 17:02:09 +0200 Subject: [PATCH] fix(components): prevent postChange event emitting before post-tabs loads --- .changeset/fifty-peaches-turn.md | 5 +++++ .../src/components/post-tabs/post-tabs.tsx | 14 ++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 .changeset/fifty-peaches-turn.md 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() {