|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { FC, useEffect } from 'react';
|
|
|
+import React, { FC, useEffect, useState } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import { IPageHasId } from '../../../interfaces/page';
|
|
|
@@ -63,6 +63,7 @@ type ItemsTreeProps = {
|
|
|
const renderByInitialNode = (
|
|
|
initialNode: ItemNode,
|
|
|
isEnableActions: boolean,
|
|
|
+ isScrolled: boolean,
|
|
|
targetPathOrId?: string,
|
|
|
isEnabledAttachTitleHeader?: boolean,
|
|
|
onClickDuplicateMenuItem?: (pageId: string, path: string) => void,
|
|
|
@@ -82,6 +83,7 @@ const renderByInitialNode = (
|
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
|
onClickRenameMenuItem={onClickRenameMenuItem}
|
|
|
onClickDeleteMenuItem={onClickDeleteMenuItem}
|
|
|
+ isScrolled={isScrolled}
|
|
|
/>
|
|
|
</ul>
|
|
|
);
|
|
|
@@ -117,10 +119,13 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
|
const { open: openRenameModal } = usePageRenameModal();
|
|
|
const { open: openDeleteModal } = usePageDeleteModal();
|
|
|
+ const [isScrolled, setIsScrolled] = useState(false);
|
|
|
+
|
|
|
|
|
|
useEffect(() => {
|
|
|
document.addEventListener('targetItemRendered', () => {
|
|
|
scrollTargetItem();
|
|
|
+ setIsScrolled(true);
|
|
|
});
|
|
|
}, []);
|
|
|
|
|
|
@@ -165,7 +170,8 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
if (ancestorsChildrenData != null && rootPageData != null) {
|
|
|
const initialNode = generateInitialNodeAfterResponse(ancestorsChildrenData.ancestorsChildren, new ItemNode(rootPageData.rootPage));
|
|
|
return renderByInitialNode(
|
|
|
- initialNode, isEnableActions, targetPathOrId, isEnabledAttachTitleHeader, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ initialNode, isEnableActions, isScrolled, targetPathOrId, isEnabledAttachTitleHeader, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -175,7 +181,8 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
if (targetAndAncestorsData != null) {
|
|
|
const initialNode = generateInitialNodeBeforeResponse(targetAndAncestorsData.targetAndAncestors);
|
|
|
return renderByInitialNode(
|
|
|
- initialNode, isEnableActions, targetPathOrId, isEnabledAttachTitleHeader, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ initialNode, isEnableActions, isScrolled, targetPathOrId, isEnabledAttachTitleHeader, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
);
|
|
|
}
|
|
|
|