Skip to content

Commit

Permalink
Revert to use open state
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Jan 23, 2025
1 parent 3f111ad commit b2ffe65
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/dialog/root/useDialogRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function useDialogRoot(params: useDialogRoot.Parameters): useDialogRoot.R
},
});

useScrollLock(mounted && modal, popupElement);
useScrollLock(open && modal, popupElement);

const handleFloatingUIOpenChange = (
nextOpen: boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/menu/root/useMenuRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function useMenuRoot(parameters: useMenuRoot.Parameters): useMenuRoot.Ret

const { mounted, setMounted, transitionStatus } = useTransitionStatus(open);

useScrollLock(mounted && modal, triggerElement);
useScrollLock(open && modal, triggerElement);

const setOpen = useEventCallback(
(nextOpen: boolean, event?: Event, reason?: OpenChangeReason) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function useSelectPositioner(
): useSelectPositioner.ReturnValue {
const { open, alignItemToTrigger, mounted, triggerElement, modal } = useSelectRootContext();

useScrollLock((alignItemToTrigger || modal) && mounted, triggerElement);
useScrollLock((alignItemToTrigger || modal) && open, triggerElement);

const positioning = useAnchorPositioning({
...params,
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/utils/useScrollLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ export function useScrollLock(enabled = true, referenceElement?: Element | null)
);

usePreventScroll({
// react-aria will remove the scrollbar offset immediately upon close, since we use `open`,
// not `mounted`, to disable/enable the scroll lock. However since there are no inset
// scrollbars, no layouting issues occur.
isDisabled: !isReactAriaHook,
});

Expand Down

0 comments on commit b2ffe65

Please sign in to comment.