Fix import and export too early bug

This commit is contained in:
1ilit 2023-09-19 15:49:50 +03:00
parent 982d2daa11
commit 364866a70a

View File

@ -797,6 +797,7 @@ export default function ControlPanel(props) {
saveAs(blob, `${exportData.filename}.${exportData.extension}`);
} else if (visible === MODAL.IMPORT) {
if (error.type !== ERROR.ERROR) {
setSettings((prev) => ({ ...prev, pan: { x: 0, y: 0 } }));
overwriteDiagram();
setData(null);
setVisible(MODAL.NONE);
@ -819,7 +820,13 @@ export default function ControlPanel(props) {
centered
closeOnEsc={true}
okText={`${visible === MODAL.IMPORT ? "Import" : "Export"}`}
okButtonProps={{ disabled: error.type === ERROR.ERROR }}
okButtonProps={{
disabled:
(visible === MODAL.IMPORT &&
(error.type === ERROR.ERROR || !data)) ||
((visible === MODAL.IMG || visible === MODAL.CODE) &&
!exportData.data),
}}
cancelText="Cancel"
width={520}
>