Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/luthor/src/core/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ export function Dialog({
useLayoutEffect(() => {
if (isOpen && anchorRef.current) {
setThemeStyle(getOverlayThemeStyleFromElement(anchorRef.current));
} else if (!isOpen) {
setThemeStyle(undefined);
}
}, [isOpen]);

Expand Down Expand Up @@ -444,7 +446,10 @@ export function Dialog({
}, [isOpen, onClose]);

const anchor = <span ref={anchorRef} className="luthor-dialog-anchor" hidden />;
if (!isOpen || typeof document === "undefined") return anchor;
// Mount the portal only once the theme is read: a first paint without it had
// no background, and the theme transition then faded the panel in from
// transparent.
if (!isOpen || !themeStyle || typeof document === "undefined") return anchor;

const overlay = (
<div className="luthor-dialog-overlay luthor-dialog-overlay--portal" style={themeStyle}>
Expand Down
Loading