2
0
Shun Miyazawa 4 жил өмнө
parent
commit
7b2dc6afd7

+ 6 - 2
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -119,6 +119,11 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     }),
     }),
   }));
   }));
 
 
+  const getParentPagePath = (pagePath: string) => {
+    const dirname = nodePath.dirname(page.path as string);
+    return dirname === '/' ? '' : dirname;
+  };
+
   const hasChildren = useCallback((): boolean => {
   const hasChildren = useCallback((): boolean => {
     return currentChildren != null && currentChildren.length > 0;
     return currentChildren != null && currentChildren.length > 0;
   }, [currentChildren]);
   }, [currentChildren]);
@@ -226,8 +231,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
       return;
       return;
     }
     }
 
 
-    const parentPath = nodePath.dirname(page.path as string);
-
+    const parentPath = getParentPagePath(page.path as string);
     redirectToEditor(parentPath, inputText);
     redirectToEditor(parentPath, inputText);
   };
   };