From 1442139d1608e61b1418989367a2f6beb3b43716 Mon Sep 17 00:00:00 2001 From: Jasmin Date: Mon, 22 Jul 2024 16:55:10 +0200 Subject: [PATCH 1/2] fix(prevent-scroll): wait for presence to finish before enabling scroll --- .changeset/early-geckos-sort.md | 5 +++++ packages/core/src/combobox/combobox-content.tsx | 2 +- packages/core/src/dialog/dialog-content.tsx | 2 +- packages/core/src/menu/menu-content.tsx | 2 +- packages/core/src/popover/popover-content.tsx | 2 +- packages/core/src/select/select-content.tsx | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/early-geckos-sort.md diff --git a/.changeset/early-geckos-sort.md b/.changeset/early-geckos-sort.md new file mode 100644 index 000000000..84712ec0a --- /dev/null +++ b/.changeset/early-geckos-sort.md @@ -0,0 +1,5 @@ +--- +"@kobalte/core": patch +--- + +fix(prevent-scroll): wait for presence to finish before enabling scroll diff --git a/packages/core/src/combobox/combobox-content.tsx b/packages/core/src/combobox/combobox-content.tsx index 35b1c2e20..ab33365e0 100644 --- a/packages/core/src/combobox/combobox-content.tsx +++ b/packages/core/src/combobox/combobox-content.tsx @@ -120,7 +120,7 @@ export function ComboboxContent( createPreventScroll({ element: () => ref ?? null, - enabled: () => context.isOpen() && context.preventScroll(), + enabled: () => context.contentPresent() && context.preventScroll(), }); createFocusScope( diff --git a/packages/core/src/dialog/dialog-content.tsx b/packages/core/src/dialog/dialog-content.tsx index df3e8e1e8..846bf6f94 100644 --- a/packages/core/src/dialog/dialog-content.tsx +++ b/packages/core/src/dialog/dialog-content.tsx @@ -202,7 +202,7 @@ export function DialogContent( createPreventScroll({ element: () => ref ?? null, - enabled: () => context.isOpen() && context.preventScroll(), + enabled: () => context.contentPresent() && context.preventScroll(), }); createFocusScope( diff --git a/packages/core/src/menu/menu-content.tsx b/packages/core/src/menu/menu-content.tsx index 1a661cc18..0556b9cfb 100644 --- a/packages/core/src/menu/menu-content.tsx +++ b/packages/core/src/menu/menu-content.tsx @@ -37,7 +37,7 @@ export function MenuContent( createPreventScroll({ element: () => ref ?? null, - enabled: () => context.isOpen() && rootContext.preventScroll(), + enabled: () => context.contentPresent() && rootContext.preventScroll(), }); return ( diff --git a/packages/core/src/popover/popover-content.tsx b/packages/core/src/popover/popover-content.tsx index 29500b341..13e569ea7 100644 --- a/packages/core/src/popover/popover-content.tsx +++ b/packages/core/src/popover/popover-content.tsx @@ -206,7 +206,7 @@ export function PopoverContent( createPreventScroll({ element: () => ref ?? null, - enabled: () => context.isOpen() && context.preventScroll(), + enabled: () => context.contentPresent() && context.preventScroll(), }); createFocusScope( diff --git a/packages/core/src/select/select-content.tsx b/packages/core/src/select/select-content.tsx index 6a97715d5..310de3a0a 100644 --- a/packages/core/src/select/select-content.tsx +++ b/packages/core/src/select/select-content.tsx @@ -111,7 +111,7 @@ export function SelectContent( createPreventScroll({ element: () => ref ?? null, - enabled: () => context.isOpen() && context.preventScroll(), + enabled: () => context.contentPresent() && context.preventScroll(), }); createFocusScope( From 9009ea1605ba7791823be09017aee9c52c76f476 Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Mon, 22 Jul 2024 17:03:20 +0200 Subject: [PATCH 2/2] Delete .changeset/early-geckos-sort.md --- .changeset/early-geckos-sort.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/early-geckos-sort.md diff --git a/.changeset/early-geckos-sort.md b/.changeset/early-geckos-sort.md deleted file mode 100644 index 84712ec0a..000000000 --- a/.changeset/early-geckos-sort.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@kobalte/core": patch ---- - -fix(prevent-scroll): wait for presence to finish before enabling scroll