diff --git a/striker-ui/components/Dialog/Dialog.tsx b/striker-ui/components/Dialog/Dialog.tsx index 285a7d90..b080dea9 100644 --- a/striker-ui/components/Dialog/Dialog.tsx +++ b/striker-ui/components/Dialog/Dialog.tsx @@ -29,7 +29,9 @@ const Dialog: ForwardRefExoticComponent< } = props; const { - open: externalOpen = false, + // Do not initialize the external open state because we need it to + // determine whether the dialog is controlled or uncontrolled. + open: externalOpen, PaperProps: paperProps = {}, ...restDialogProps } = dialogProps; @@ -39,8 +41,8 @@ const Dialog: ForwardRefExoticComponent< const [controlOpen, setControlOpen] = useState(openInitially); const open = useMemo( - () => (ref ? controlOpen : externalOpen), - [controlOpen, externalOpen, ref], + () => externalOpen ?? controlOpen, + [controlOpen, externalOpen], ); const children = useMemo(