Просмотр исходного кода

136640 close modal when editor is null

soumaeda 2 лет назад
Родитель
Сommit
d1fc6c6ccb

+ 1 - 1
apps/app/src/components/PageEditor/DrawioModal.tsx

@@ -57,7 +57,7 @@ export const DrawioModal = (): JSX.Element => {
   const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey);
   const editor = codeMirrorEditor?.view;
 
-  if ((isOpened || isOpendInEditor) && editorKey == null && drawioModalData?.onSave == null) {
+  if (isOpendInEditor && editor == null) {
     closeDrawioModalInEdior();
   }
 

+ 4 - 4
packages/editor/src/stores/use-drawio.ts

@@ -7,7 +7,7 @@ type DrawioModalSaveHandler = () => void;
 
 type DrawioModalStatus = {
   isOpened: boolean,
-  editorKey: string,
+  editorKey: string | undefined,
   onSave?: DrawioModalSaveHandler,
 }
 
@@ -22,18 +22,18 @@ type DrawioModalStatusUtils = {
 export const useDrawioModalForEditor = (status?: DrawioModalStatus): SWRResponse<DrawioModalStatus, Error> & DrawioModalStatusUtils => {
   const initialData: DrawioModalStatus = {
     isOpened: false,
-    editorKey: '',
+    editorKey: undefined,
   };
   const swrResponse = useSWRStatic<DrawioModalStatus, Error>('drawioModalStatus', status, { fallbackData: initialData });
 
   const { mutate } = swrResponse;
 
-  const open = useCallback((editorKey: string, onSave?: DrawioModalSaveHandler): void => {
+  const open = useCallback((editorKey: string | undefined, onSave?: DrawioModalSaveHandler): void => {
     mutate({ isOpened: true, editorKey, onSave });
   }, [mutate]);
 
   const close = useCallback((): void => {
-    mutate({ isOpened: false, editorKey: '', onSave: undefined });
+    mutate({ isOpened: false, editorKey: undefined, onSave: undefined });
   }, [mutate]);
 
   return {