Browse Source

Revert "134432 remove null guard"

This reverts commit ac8896e9de115005d31e16daa17f41761dadf8ac.
soumaeda 2 years ago
parent
commit
8243821632

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

@@ -102,7 +102,7 @@ export const HandsontableModal = (): JSX.Element => {
   const debouncedHandleWindowExpandedChange = debounce(100, handleWindowExpandedChange);
 
   const handleModalOpen = () => {
-    const initTableInstance = table == null ? defaultMarkdownTable : table.clone();
+    const initTableInstance = table == null ? defaultMarkdownTable : table;
     setMarkdownTable(table ?? defaultMarkdownTable);
     setMarkdownTableOnInit(initTableInstance);
     debouncedHandleWindowExpandedChange();

+ 3 - 0
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -189,6 +189,9 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
   const openTableModalHandler = useCallback(() => {
     const editor = codeMirrorEditor?.view;
     const markdownTable = mtu.getMarkdownTable(editor);
+    if (markdownTable == null) {
+      return;
+    }
     openHandsontableModal(markdownTable, editor);
   }, [codeMirrorEditor]);
 

+ 1 - 1
apps/app/src/stores/modal.tsx

@@ -516,7 +516,7 @@ type HandsontableModalStatus = {
 
 type HandsontableModalStatusUtils = {
   open(
-    table?: MarkdownTable,
+    table: MarkdownTable,
     editor?: any,
     autoFormatMarkdownTable?: boolean,
     onSave?: HandsonTableModalSaveHandler