Skip to content

Commit 75663e4

Browse files
committed
fix(sheet): Added fixes required for Concurrent Rendering
1 parent c0b29a8 commit 75663e4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/sheet/src/Sheet.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, useRef, useState } from "react";
1+
import { forwardRef, useEffect, useRef, useState } from "react";
22
import cn from "classnames";
33
import { BaseDialogProps, Dialog } from "@react-md/dialog";
44
import { bem, LabelRequiredForA11y } from "@react-md/utils";
@@ -117,9 +117,11 @@ export const Sheet = forwardRef<HTMLDivElement, SheetProps>(function Sheet(
117117
// when sheets are not unmounted on exit, need to set it to hidden so that
118118
// tabbing no longer focuses any of the elements inside
119119
const [hidden, setHidden] = useState(!visible && !temporary);
120-
if (hidden && visible) {
121-
setHidden(false);
122-
}
120+
useEffect(() => {
121+
if (hidden && visible) {
122+
setHidden(false);
123+
}
124+
}, [hidden, visible]);
123125

124126
return (
125127
<Dialog

0 commit comments

Comments
 (0)