fix(striker-ui): prioritize parent open state in Dialog

main
Tsu-ba-me 1 year ago
parent e8fe92321e
commit c05932c261
  1. 8
      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<boolean>(openInitially);
const open = useMemo<boolean>(
() => (ref ? controlOpen : externalOpen),
[controlOpen, externalOpen, ref],
() => externalOpen ?? controlOpen,
[controlOpen, externalOpen],
);
const children = useMemo<ReactNode>(

Loading…
Cancel
Save