Skip to content

Commit

Permalink
fix: also remove RTG from scrim too
Browse files Browse the repository at this point in the history
  • Loading branch information
artmsilva committed Jun 6, 2024
1 parent ddebd88 commit 59531b6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/kit/src/scrim/Scrim.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useTransition } from "react";
import { styled, theme, css as wpCSS } from "../theme";
import type * as WPDS from "../theme";
import type { Token } from "@stitches/react/types/theme";
Expand Down Expand Up @@ -63,21 +63,26 @@ export const Scrim = React.forwardRef<HTMLDivElement, ScrimProps>(
}
}, [open, lockScroll]);

const [isPending, startTransition] = useTransition();
const [isMounted, setIsMounted] = React.useState(false);

React.useEffect(() => {
if (open) {
setIsMounted(true);
}
startTransition(() => {
if (open) {
setIsMounted(true);
}
});
}, [open]);

const handleTransitionEnd = () => {
if (!open) {
setIsMounted(false);
startTransition(() => {
setIsMounted(false);
});
}
};

return isMounted ? (
return isMounted || isPending ? (
<StyledContainer
data-state={open ? "open" : "closed"}
ref={ref}
Expand Down

0 comments on commit 59531b6

Please sign in to comment.