From 4a25bcdf2aa3ae73acc4f8995cbac8e11c91e5c1 Mon Sep 17 00:00:00 2001 From: "L." Date: Sun, 25 Aug 2024 13:45:47 +0200 Subject: [PATCH 1/3] fix(Toast): check if window exists to run startTimer in CSR only --- packages/radix-vue/src/Toast/ToastRootImpl.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/radix-vue/src/Toast/ToastRootImpl.vue b/packages/radix-vue/src/Toast/ToastRootImpl.vue index e04f4d236..c44a15609 100644 --- a/packages/radix-vue/src/Toast/ToastRootImpl.vue +++ b/packages/radix-vue/src/Toast/ToastRootImpl.vue @@ -80,6 +80,11 @@ const remainingRaf = useRafFn(() => { function startTimer(duration: number) { if (!duration || duration === Number.POSITIVE_INFINITY) return + // startTimer is used inside a watch with immediate set to true. + // This results in code execution during SSR. + // Ensure this code only runs in a browser environment + if (typeof window === 'undefined') + return window.clearTimeout(closeTimerRef.value) closeTimerStartTimeRef.value = new Date().getTime() closeTimerRef.value = window.setTimeout(handleClose, duration) From 6a7306abede9415ef16ea1eb5a918b814baf7be9 Mon Sep 17 00:00:00 2001 From: "L." Date: Mon, 26 Aug 2024 10:23:56 +0200 Subject: [PATCH 2/3] use isClient to to test if it's CSR --- packages/radix-vue/src/Toast/ToastRootImpl.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/radix-vue/src/Toast/ToastRootImpl.vue b/packages/radix-vue/src/Toast/ToastRootImpl.vue index c44a15609..62efb0af1 100644 --- a/packages/radix-vue/src/Toast/ToastRootImpl.vue +++ b/packages/radix-vue/src/Toast/ToastRootImpl.vue @@ -1,4 +1,5 @@