diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 5f9df8f7..b3f64849 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -27,6 +27,7 @@ export type TPrimaryPageName = keyof typeof PRIMARY_PAGE_MAP type TPrimaryPageContext = { navigate: (page: TPrimaryPageName) => void current: TPrimaryPageName | null + display: boolean } type TSecondaryPageContext = { @@ -200,7 +201,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { setPrimaryPages((prev) => [...prev, { name: page, element: PRIMARY_PAGE_MAP[page] }]) } setCurrentPrimaryPage(page) - PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop() if (isSmallScreen) { clearSecondaryPages() } @@ -249,7 +249,8 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { (null) const smallScreenLastScrollTopRef = useRef(0) const { isSmallScreen } = useScreenSize() - const { current } = usePrimaryPage() + const { current, display } = usePrimaryPage() useImperativeHandle( ref, @@ -44,7 +44,7 @@ const PrimaryPageLayout = forwardRef( useEffect(() => { if (isSmallScreen) { if (smallScreenScrollAreaRef.current?.checkVisibility()) { - window.scrollTo({ top: smallScreenLastScrollTopRef.current }) + window.scrollTo({ top: smallScreenLastScrollTopRef.current, behavior: 'instant' }) } const handleScroll = () => { if (smallScreenScrollAreaRef.current?.checkVisibility()) { @@ -56,7 +56,7 @@ const PrimaryPageLayout = forwardRef( window.removeEventListener('scroll', handleScroll) } } - }, [current, isSmallScreen]) + }, [current, isSmallScreen, display]) if (isSmallScreen) { return (