kosei-n 1 год назад
Родитель
Сommit
258dc25861

+ 15 - 3
apps/app/src/components/PageSelectModal/PageSelectModal.tsx

@@ -1,8 +1,11 @@
 import type { FC } from 'react';
 import type { FC } from 'react';
-import { Suspense, useState, useCallback } from 'react';
+import {
+  Suspense, useState, useCallback, useEffect,
+} from 'react';
 
 
 import nodePath from 'path';
 import nodePath from 'path';
 
 
+import { pathUtils } from '@growi/core/dist/utils';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 import {
 import {
   Modal, ModalHeader, ModalBody, ModalFooter, Button,
   Modal, ModalHeader, ModalBody, ModalFooter, Button,
@@ -64,9 +67,18 @@ export const PageSelectModal: FC = () => {
     closeModal();
     closeModal();
   }, [clickedParentPagePath, closeModal, currentPage?.path, pagePathRenameHandler]);
   }, [clickedParentPagePath, closeModal, currentPage?.path, pagePathRenameHandler]);
 
 
-  const targetPathOrId = clickedParentPagePath;
+  if (currentPage == null) {
+    return;
+  }
+
+  const parentPagePath = pathUtils.addTrailingSlash(nodePath.dirname(currentPage.path));
+
+  const targetPathOrId = clickedParentPagePath || parentPagePath;
+
+  const targetPath = clickedParentPagePath || parentPagePath;
 
 
-  const targetPath = clickedParentPagePath || '/';
+  // console.log(clickedParentPagePath);
+  // console.log(targetPathOrId);
 
 
   if (isGuestUser == null) {
   if (isGuestUser == null) {
     return null;
     return null;

+ 5 - 0
apps/app/src/components/TreeItem/TreeItemLayout.tsx

@@ -25,11 +25,16 @@ const markTarget = (page: IPageForItem, children: ItemNode[], targetPathOrId?: N
     return;
     return;
   }
   }
 
 
+  // console.log(targetPathOrId);
+
   page.isTarget = page.path === targetPathOrId;
   page.isTarget = page.path === targetPathOrId;
 
 
+  // console.log(page.path);
+
   children.forEach((node) => {
   children.forEach((node) => {
     if (node.page._id === targetPathOrId || node.page.path === targetPathOrId) {
     if (node.page._id === targetPathOrId || node.page.path === targetPathOrId) {
       node.page.isTarget = true;
       node.page.isTarget = true;
+      console.log(node.page);
     }
     }
     else {
     else {
       node.page.isTarget = false;
       node.page.isTarget = false;