Skip to content

Commit

Permalink
use targetpath to judge has children
Browse files Browse the repository at this point in the history
  • Loading branch information
reiji-h committed Jan 9, 2025
1 parent 69a05f5 commit f62e0ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const moduleClass = styles['page-tree-item'] ?? '';

const logger = loggerFactory('growi:cli:Item');

export const PageTreeItem: FC<TreeItemProps> = (props) => {
export const PageTreeItem = (props:TreeItemProps): JSX.Element => {
const router = useRouter();

const getNewPathAfterMoved = (droppedPagePath: string, newParentPagePath: string): string => {
Expand Down Expand Up @@ -186,6 +186,7 @@ export const PageTreeItem: FC<TreeItemProps> = (props) => {
return (
<TreeItemLayout
className={moduleClass}
targetPath={props.targetPath}
targetPathOrId={props.targetPathOrId}
itemLevel={props.itemLevel}
itemNode={props.itemNode}
Expand Down
7 changes: 4 additions & 3 deletions apps/app/src/client/components/TreeItem/TreeItemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const TreeItemLayout = (props: TreeItemLayoutProps): JSX.Element => {
className, itemClassName,
indentSize = 10,
itemLevel: baseItemLevel = 1,
itemNode, targetPathOrId, isOpen: _isOpen = false,
itemNode, targetPath, targetPathOrId, isOpen: _isOpen = false,
onRenamed, onClick, onClickDuplicateMenuItem, onClickDeleteMenuItem, onWheelClick,
isEnableActions, isReadOnlyUser, isWipPageShown = true,
itemRef, itemClass,
Expand Down Expand Up @@ -75,8 +75,8 @@ export const TreeItemLayout = (props: TreeItemLayoutProps): JSX.Element => {
const hasDescendants = descendantCount > 0 || isChildrenLoaded;

const hasChildren = useCallback((): boolean => {
return currentChildren != null && currentChildren.length > 0;
}, [currentChildren]);
return page.path != null && targetPath.startsWith(page.path);
}, [page, targetPath]);

const onClickLoadChildren = useCallback(() => {
setIsOpen(!isOpen);
Expand Down Expand Up @@ -108,6 +108,7 @@ export const TreeItemLayout = (props: TreeItemLayoutProps): JSX.Element => {
isReadOnlyUser,
isOpen: false,
isWipPageShown,
targetPath,
targetPathOrId,
onRenamed,
onClickDuplicateMenuItem,
Expand Down

0 comments on commit f62e0ed

Please sign in to comment.