From b0be26d67feab467ac5862edd82e52df03a5091c Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Sun, 10 Nov 2024 19:20:24 +0100 Subject: [PATCH] fix(Toaster): teleport to `body` Resolves #2404 --- src/runtime/components/Toaster.vue | 34 ++++++---- test/components/Toast.spec.ts | 2 +- .../__snapshots__/Toast-vue.spec.ts.snap | 64 ++++++++++++++----- .../__snapshots__/Toast.spec.ts.snap | 64 ++++++++++++++----- 4 files changed, 118 insertions(+), 46 deletions(-) diff --git a/src/runtime/components/Toaster.vue b/src/runtime/components/Toaster.vue index 349c86bf..b6af5d84 100644 --- a/src/runtime/components/Toaster.vue +++ b/src/runtime/components/Toaster.vue @@ -19,6 +19,11 @@ export interface ToasterProps extends Omit * @defaultValue true */ expand?: boolean + /** + * Render the toaster in a portal. + * @defaultValue true + */ + portal?: boolean class?: any ui?: Partial } @@ -44,6 +49,7 @@ import UToast from './Toast.vue' const props = withDefaults(defineProps(), { expand: true, + portal: true, duration: 5000 }) defineSlots() @@ -120,18 +126,20 @@ function getOffset(index: number) { @click="toast.click && toast.click(toast)" /> - + + + diff --git a/test/components/Toast.spec.ts b/test/components/Toast.spec.ts index 100ae54a..c07db3cd 100644 --- a/test/components/Toast.spec.ts +++ b/test/components/Toast.spec.ts @@ -12,7 +12,7 @@ const ToastWrapper = defineComponent({ ClientOnly }, inheritAttrs: false, - template: ` + template: `