Skip to content

Commit

Permalink
fix: give ServerSideDocumentFallback callback
Browse files Browse the repository at this point in the history
  • Loading branch information
p-sw committed Jul 19, 2024
1 parent d0af00d commit ad62a4e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
46 changes: 24 additions & 22 deletions packages/react/components/Dialog/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,32 @@ const DialogOverlay = React.forwardRef<HTMLDivElement, DialogOverlay>(

return (
<ServerSideDocumentFallback>
{ReactDOM.createPortal(
<div
{...otherPropsExtracted}
id={ids.dialog}
ref={ref}
className={dialogOverlayVariant(variantProps)}
onClick={(e) => {
if (closeOnClick) {
setContext((p) => ({ ...p, opened: false }));
}
onClick?.(e);
}}
>
{() =>
ReactDOM.createPortal(
<div
className={
"w-screen max-w-full min-h-screen flex flex-col justify-center items-center"
}
{...otherPropsExtracted}
id={ids.dialog}
ref={ref}
className={dialogOverlayVariant(variantProps)}
onClick={(e) => {
if (closeOnClick) {
setContext((p) => ({ ...p, opened: false }));
}
onClick?.(e);
}}
>
{/* Layer for overflow positioning */}
{children}
</div>
</div>,
document.body,
)}
<div
className={
"w-screen max-w-full min-h-screen flex flex-col justify-center items-center"
}
>
{/* Layer for overflow positioning */}
{children}
</div>
</div>,
document.body,
)
}
</ServerSideDocumentFallback>
);
},
Expand Down
36 changes: 19 additions & 17 deletions packages/react/components/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,25 @@ const DrawerOverlay = forwardRef<HTMLDivElement, DrawerOverlayProps>(

return (
<ServerSideDocumentFallback>
{createPortal(
<Comp
{...restPropsExtracted}
className={drawerOverlayVariant({
...variantProps,
opened: state.isDragging ? true : state.opened,
})}
onClick={onOutsideClick}
style={{
backdropFilter,
WebkitBackdropFilter: backdropFilter,
transitionDuration: state.isDragging ? "0s" : undefined,
}}
ref={ref}
/>,
document.body,
)}
{() =>
createPortal(
<Comp
{...restPropsExtracted}
className={drawerOverlayVariant({
...variantProps,
opened: state.isDragging ? true : state.opened,
})}
onClick={onOutsideClick}
style={{
backdropFilter,
WebkitBackdropFilter: backdropFilter,
transitionDuration: state.isDragging ? "0s" : undefined,
}}
ref={ref}
/>,
document.body,
)
}
</ServerSideDocumentFallback>
);
},
Expand Down

0 comments on commit ad62a4e

Please sign in to comment.