From 1b808e3b921127d1924a87f33aca79059352a68a Mon Sep 17 00:00:00 2001 From: SHYAKA Davis <87414827+shyakadavis@users.noreply.github.com> Date: Fri, 23 Feb 2024 20:56:19 +0200 Subject: [PATCH] fix: reset background color on close (#57) Co-authored-by: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> Co-authored-by: Hunter Johnston <64506580+huntabyte@users.noreply.github.com> --- .changeset/eleven-swans-swim.md | 5 +++++ src/lib/internal/vaul.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/eleven-swans-swim.md diff --git a/.changeset/eleven-swans-swim.md b/.changeset/eleven-swans-swim.md new file mode 100644 index 0000000..f1db4f6 --- /dev/null +++ b/.changeset/eleven-swans-swim.md @@ -0,0 +1,5 @@ +--- +"vaul-svelte": patch +--- + +fix: reset background color on close diff --git a/src/lib/internal/vaul.ts b/src/lib/internal/vaul.ts index 7a78483..bbdc732 100644 --- a/src/lib/internal/vaul.ts +++ b/src/lib/internal/vaul.ts @@ -482,6 +482,12 @@ export function createVaul(props: CreateVaulProps) { const $direction = get(direction); if (open) { + // setting original styles initially + set(document.body, { + background: document.body.style.backgroundColor || document.body.style.background, + }); + + // setting body styles, with cache ignored, so that we can get correct original styles in reset set( document.body, {