From 4df45bf940edae633ca8efbb7536592063edcf87 Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Mon, 8 Jan 2024 23:28:19 +0100 Subject: [PATCH 1/3] feat: allow disabling prevent scroll --- packages/core/src/dialog/dialog-content.tsx | 2 +- packages/core/src/dialog/dialog-root.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/dialog/dialog-content.tsx b/packages/core/src/dialog/dialog-content.tsx index 80547220..f7a21d35 100644 --- a/packages/core/src/dialog/dialog-content.tsx +++ b/packages/core/src/dialog/dialog-content.tsx @@ -176,7 +176,7 @@ export function DialogContent(props: DialogContentProps) { createPreventScroll({ ownerRef: () => ref, - isDisabled: () => !(context.isOpen() && (context.modal() || context.preventScroll())), + isDisabled: () => !(context.isOpen() && context.preventScroll()), }); createFocusScope( diff --git a/packages/core/src/dialog/dialog-root.tsx b/packages/core/src/dialog/dialog-root.tsx index df25b5fc..ac359358 100644 --- a/packages/core/src/dialog/dialog-root.tsx +++ b/packages/core/src/dialog/dialog-root.tsx @@ -81,7 +81,7 @@ export function DialogRoot(props: DialogRootProps) { const context: DialogContextValue = { isOpen: disclosureState.isOpen, modal: () => props.modal ?? true, - preventScroll: () => props.preventScroll ?? false, + preventScroll: () => props.preventScroll ?? context.modal(), contentId, titleId, descriptionId, From fc3a88853fe5afd680ad3b4bb5b1541c911c4f9e Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Thu, 11 Jan 2024 21:43:43 +0100 Subject: [PATCH 2/3] feat: allow disabling prevent scroll in all components --- packages/core/src/combobox/combobox-base.tsx | 2 +- packages/core/src/combobox/combobox-content.tsx | 2 +- packages/core/src/menu/menu-content.tsx | 2 +- packages/core/src/menu/menu-root.tsx | 2 +- packages/core/src/popover/popover-content.tsx | 2 +- packages/core/src/popover/popover-root.tsx | 2 +- packages/core/src/select/select-base.tsx | 2 +- packages/core/src/select/select-content.tsx | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/combobox/combobox-base.tsx b/packages/core/src/combobox/combobox-base.tsx index add6e69b..8fe23823 100644 --- a/packages/core/src/combobox/combobox-base.tsx +++ b/packages/core/src/combobox/combobox-base.tsx @@ -747,7 +747,7 @@ export function ComboboxBase(props: ComboboxBaseProps< isMultiple: () => access(local.selectionMode) === "multiple", isVirtualized: () => local.virtualized ?? false, isModal: () => local.modal ?? false, - preventScroll: () => local.preventScroll ?? false, + preventScroll: () => local.preventScroll ?? context.isModal(), allowsEmptyCollection: () => local.allowsEmptyCollection ?? false, shouldFocusWrap: () => local.shouldFocusWrap ?? false, removeOnBackspace: () => local.removeOnBackspace ?? true, diff --git a/packages/core/src/combobox/combobox-content.tsx b/packages/core/src/combobox/combobox-content.tsx index ee8cec67..313ad69e 100644 --- a/packages/core/src/combobox/combobox-content.tsx +++ b/packages/core/src/combobox/combobox-content.tsx @@ -98,7 +98,7 @@ export function ComboboxContent(props: ComboboxContentProps) { createPreventScroll({ ownerRef: () => ref, - isDisabled: () => !(context.isOpen() && (context.isModal() || context.preventScroll())), + isDisabled: () => !(context.isOpen() && context.preventScroll()), }); createFocusScope( diff --git a/packages/core/src/menu/menu-content.tsx b/packages/core/src/menu/menu-content.tsx index 692e9496..426af814 100644 --- a/packages/core/src/menu/menu-content.tsx +++ b/packages/core/src/menu/menu-content.tsx @@ -20,7 +20,7 @@ export function MenuContent(props: MenuContentProps) { createPreventScroll({ ownerRef: () => ref, - isDisabled: () => !(context.isOpen() && (rootContext.isModal() || rootContext.preventScroll())), + isDisabled: () => !(context.isOpen() && rootContext.preventScroll()), }); return (ref = el), local.ref)} {...others} />; diff --git a/packages/core/src/menu/menu-root.tsx b/packages/core/src/menu/menu-root.tsx index d11a003d..f10e90a9 100644 --- a/packages/core/src/menu/menu-root.tsx +++ b/packages/core/src/menu/menu-root.tsx @@ -69,7 +69,7 @@ export function MenuRoot(props: MenuRootProps) { const context: MenuRootContextValue = { isModal: () => local.modal ?? true, - preventScroll: () => local.preventScroll ?? false, + preventScroll: () => local.preventScroll ?? context.isModal(), forceMount: () => local.forceMount ?? false, generateId: createGenerateId(() => local.id!), }; diff --git a/packages/core/src/popover/popover-content.tsx b/packages/core/src/popover/popover-content.tsx index ad597707..05c1b5bf 100644 --- a/packages/core/src/popover/popover-content.tsx +++ b/packages/core/src/popover/popover-content.tsx @@ -175,7 +175,7 @@ export function PopoverContent(props: PopoverContentProps) { createPreventScroll({ ownerRef: () => ref, - isDisabled: () => !(context.isOpen() && (context.isModal() || context.preventScroll())), + isDisabled: () => !(context.isOpen() && context.preventScroll()), }); createFocusScope( diff --git a/packages/core/src/popover/popover-root.tsx b/packages/core/src/popover/popover-root.tsx index 3b34aaa6..0a1bb034 100644 --- a/packages/core/src/popover/popover-root.tsx +++ b/packages/core/src/popover/popover-root.tsx @@ -124,7 +124,7 @@ export function PopoverRoot(props: PopoverRootProps) { dataset, isOpen: disclosureState.isOpen, isModal: () => local.modal ?? false, - preventScroll: () => local.preventScroll ?? false, + preventScroll: () => local.preventScroll ?? context.isModal(), contentPresence, triggerRef, contentId, diff --git a/packages/core/src/select/select-base.tsx b/packages/core/src/select/select-base.tsx index b165b524..217f6e6e 100644 --- a/packages/core/src/select/select-base.tsx +++ b/packages/core/src/select/select-base.tsx @@ -462,7 +462,7 @@ export function SelectBase(props: SelectBaseProps access(local.selectionMode) === "multiple", isVirtualized: () => local.virtualized ?? false, isModal: () => local.modal ?? false, - preventScroll: () => local.preventScroll ?? false, + preventScroll: () => local.preventScroll ?? context.isModal(), disallowTypeAhead: () => local.disallowTypeAhead ?? false, shouldFocusWrap: () => local.shouldFocusWrap ?? false, selectedOptions, diff --git a/packages/core/src/select/select-content.tsx b/packages/core/src/select/select-content.tsx index efe5bc66..fcf5aaa0 100644 --- a/packages/core/src/select/select-content.tsx +++ b/packages/core/src/select/select-content.tsx @@ -86,7 +86,7 @@ export function SelectContent(props: SelectContentProps) { createPreventScroll({ ownerRef: () => ref, - isDisabled: () => !(context.isOpen() && (context.isModal() || context.preventScroll())), + isDisabled: () => !(context.isOpen() && context.preventScroll()), }); createFocusScope( From b63351b5768176bc868ed04eac71370b916619a9 Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Thu, 11 Jan 2024 22:20:00 +0100 Subject: [PATCH 3/3] fix: preventscroll --- packages/core/src/combobox/combobox-base.tsx | 1 - packages/core/src/dialog/dialog-root.tsx | 1 - packages/core/src/menu/menu-root.tsx | 1 - packages/core/src/popover/popover-root.tsx | 1 - packages/core/src/select/select-base.tsx | 1 - 5 files changed, 5 deletions(-) diff --git a/packages/core/src/combobox/combobox-base.tsx b/packages/core/src/combobox/combobox-base.tsx index 8fe23823..ab543f88 100644 --- a/packages/core/src/combobox/combobox-base.tsx +++ b/packages/core/src/combobox/combobox-base.tsx @@ -243,7 +243,6 @@ export function ComboboxBase(props: ComboboxBaseProps< gutter: 8, sameWidth: true, modal: false, - preventScroll: false, defaultFilter: "contains", triggerMode: "input", }, diff --git a/packages/core/src/dialog/dialog-root.tsx b/packages/core/src/dialog/dialog-root.tsx index ac359358..f109da8f 100644 --- a/packages/core/src/dialog/dialog-root.tsx +++ b/packages/core/src/dialog/dialog-root.tsx @@ -56,7 +56,6 @@ export function DialogRoot(props: DialogRootProps) { { id: defaultId, modal: true, - preventScroll: false, }, props, ); diff --git a/packages/core/src/menu/menu-root.tsx b/packages/core/src/menu/menu-root.tsx index f10e90a9..a6ef69e2 100644 --- a/packages/core/src/menu/menu-root.tsx +++ b/packages/core/src/menu/menu-root.tsx @@ -46,7 +46,6 @@ export function MenuRoot(props: MenuRootProps) { { id: defaultId, modal: true, - preventScroll: false, }, props, ); diff --git a/packages/core/src/popover/popover-root.tsx b/packages/core/src/popover/popover-root.tsx index 0a1bb034..62938f19 100644 --- a/packages/core/src/popover/popover-root.tsx +++ b/packages/core/src/popover/popover-root.tsx @@ -79,7 +79,6 @@ export function PopoverRoot(props: PopoverRootProps) { { id: defaultId, modal: false, - preventScroll: false, }, props, ); diff --git a/packages/core/src/select/select-base.tsx b/packages/core/src/select/select-base.tsx index 217f6e6e..8bd35970 100644 --- a/packages/core/src/select/select-base.tsx +++ b/packages/core/src/select/select-base.tsx @@ -204,7 +204,6 @@ export function SelectBase(props: SelectBaseProps