Skip to content

Commit

Permalink
fix(sheet): Added fixes required for Concurrent Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 27, 2021
1 parent c0b29a8 commit 75663e4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/sheet/src/Sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, useRef, useState } from "react";
import { forwardRef, useEffect, useRef, useState } from "react";
import cn from "classnames";
import { BaseDialogProps, Dialog } from "@react-md/dialog";
import { bem, LabelRequiredForA11y } from "@react-md/utils";
Expand Down Expand Up @@ -117,9 +117,11 @@ export const Sheet = forwardRef<HTMLDivElement, SheetProps>(function Sheet(
// when sheets are not unmounted on exit, need to set it to hidden so that
// tabbing no longer focuses any of the elements inside
const [hidden, setHidden] = useState(!visible && !temporary);
if (hidden && visible) {
setHidden(false);
}
useEffect(() => {
if (hidden && visible) {
setHidden(false);
}
}, [hidden, visible]);

return (
<Dialog
Expand Down

0 comments on commit 75663e4

Please sign in to comment.