|
@@ -111,19 +111,25 @@ export const PageTreeContent = memo(({ isWipPageShown }: PageTreeContentProps) =
|
|
|
const { data: sidebarScrollerRef } = useSidebarScrollerRef();
|
|
const { data: sidebarScrollerRef } = useSidebarScrollerRef();
|
|
|
const [isInitialScrollCompleted, setIsInitialScrollCompleted] = useState(false);
|
|
const [isInitialScrollCompleted, setIsInitialScrollCompleted] = useState(false);
|
|
|
|
|
|
|
|
- const rootElemRef = useRef(null);
|
|
|
|
|
|
|
+ const rootElemRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
// *************************** Scroll on init ***************************
|
|
// *************************** Scroll on init ***************************
|
|
|
const scrollOnInit = useCallback(() => {
|
|
const scrollOnInit = useCallback(() => {
|
|
|
- const scrollTargetElement = document.getElementById('grw-pagetree-current-page-item');
|
|
|
|
|
|
|
+ const rootElement = rootElemRef.current;
|
|
|
|
|
+ const scrollElement = sidebarScrollerRef?.current;
|
|
|
|
|
|
|
|
- if (sidebarScrollerRef?.current == null || scrollTargetElement == null) {
|
|
|
|
|
|
|
+ if (rootElement == null || scrollElement == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const scrollTargetElement = rootElement.querySelector<HTMLElement>('[aria-current]');
|
|
|
|
|
+
|
|
|
|
|
+ if (scrollTargetElement == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
logger.debug('scrollOnInit has invoked');
|
|
logger.debug('scrollOnInit has invoked');
|
|
|
|
|
|
|
|
- const scrollElement = sidebarScrollerRef.current;
|
|
|
|
|
|
|
|
|
|
// NOTE: could not use scrollIntoView
|
|
// NOTE: could not use scrollIntoView
|
|
|
// https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move
|
|
// https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move
|