Skip to content

Commit

Permalink
fix: make modal false scrollable (#444)
Browse files Browse the repository at this point in the history
* Fix body shift

* Make modal false scrollable
  • Loading branch information
emilkowalski authored Sep 24, 2024
1 parent 09d6ede commit b8be896
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,16 @@ export const Overlay = React.forwardRef<HTMLDivElement, React.ComponentPropsWith
const composedRef = useComposedRefs(ref, overlayRef);
const hasSnapPoints = snapPoints && snapPoints.length > 0;

// Overlay is the component that is locking scroll, removing it will unlock the scroll without having to dig into Radix's Dialog library
if (!modal) return null;

return (
<DialogPrimitive.Overlay
onMouseUp={onRelease}
ref={composedRef}
data-vaul-overlay=""
data-vaul-snap-points={isOpen && hasSnapPoints ? 'true' : 'false'}
data-vaul-snap-points-overlay={isOpen && shouldFade ? 'true' : 'false'}
style={{ visibility: modal ? 'visible' : 'hidden' }}
{...rest}
/>
);
Expand Down

0 comments on commit b8be896

Please sign in to comment.