From 824e29ceba0a7582fded70d42512c0ca236aa5c1 Mon Sep 17 00:00:00 2001 From: Johan Groth Date: Tue, 3 Sep 2024 10:35:26 +0200 Subject: [PATCH] fix(snackbar): open snackbar when created programatically The snackbar would not open if an HTML element was created and added to the DOM programatically --- src/components/snackbar/snackbar.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/snackbar/snackbar.tsx b/src/components/snackbar/snackbar.tsx index 8d298b0cee..c1a345c78e 100644 --- a/src/components/snackbar/snackbar.tsx +++ b/src/components/snackbar/snackbar.tsx @@ -129,13 +129,20 @@ export class Snackbar { private snackbarId: string; private timeoutId?: number; + private firstRender = true; public constructor() { this.snackbarId = createRandomString(); } - public componentWillLoad() { - this.isOpen = this.open; + public componentDidRender() { + if (!this.firstRender) { + return; + } + + this.firstRender = false; + + requestAnimationFrame(() => this.watchOpen()); } @Listen('changeOffset')