|
@@ -1,7 +1,6 @@
|
|
|
import React, {
|
|
import React, {
|
|
|
useCallback, useState, useEffect,
|
|
useCallback, useState, useEffect,
|
|
|
type FC, type RefObject, type RefCallback, type MouseEvent,
|
|
type FC, type RefObject, type RefCallback, type MouseEvent,
|
|
|
- useRef,
|
|
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
|
|
|
|
|
import nodePath from 'path';
|
|
import nodePath from 'path';
|
|
@@ -113,7 +112,6 @@ export const SimpleItem: FC<SimpleItemProps> = (props) => {
|
|
|
|
|
|
|
|
const { data } = useSWRxPageChildren(isOpen ? page._id : null);
|
|
const { data } = useSWRxPageChildren(isOpen ? page._id : null);
|
|
|
|
|
|
|
|
- const activeTargetRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
const itemClickHandler = useCallback((e: MouseEvent) => {
|
|
const itemClickHandler = useCallback((e: MouseEvent) => {
|
|
|
// DO NOT handle the event when e.currentTarget and e.target is different
|
|
// DO NOT handle the event when e.currentTarget and e.target is different
|
|
@@ -169,17 +167,6 @@ export const SimpleItem: FC<SimpleItemProps> = (props) => {
|
|
|
}, [data, isOpen, targetPathOrId]);
|
|
}, [data, isOpen, targetPathOrId]);
|
|
|
|
|
|
|
|
|
|
|
|
|
- // When open Sidebar, scroll into view active item.
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- if (!isOpen || data == null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- const timeoutId = setTimeout(() => {
|
|
|
|
|
- activeTargetRef.current?.scrollIntoView(true);
|
|
|
|
|
- }, 4000);
|
|
|
|
|
- return () => clearTimeout(timeoutId);
|
|
|
|
|
- }, [data, isOpen]);
|
|
|
|
|
-
|
|
|
|
|
const ItemClassFixed = itemClass ?? SimpleItem;
|
|
const ItemClassFixed = itemClass ?? SimpleItem;
|
|
|
|
|
|
|
|
const EndComponents = props.customEndComponents ?? [SimpleItemTool];
|
|
const EndComponents = props.customEndComponents ?? [SimpleItemTool];
|
|
@@ -208,7 +195,6 @@ export const SimpleItem: FC<SimpleItemProps> = (props) => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div
|
|
<div
|
|
|
- ref={page.isTarget ? activeTargetRef : null}
|
|
|
|
|
id={`pagetree-item-${page._id}`}
|
|
id={`pagetree-item-${page._id}`}
|
|
|
data-testid="grw-pagetree-item-container"
|
|
data-testid="grw-pagetree-item-container"
|
|
|
className={`grw-pagetree-item-container ${mainClassName}`}
|
|
className={`grw-pagetree-item-container ${mainClassName}`}
|