fix: scroll to top when clicking current nav item

This commit is contained in:
codytseng
2025-05-08 09:25:10 +08:00
parent bf6b96fd91
commit 23f6032808

View File

@@ -196,11 +196,15 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
}, [])
const navigatePrimaryPage = (page: TPrimaryPageName) => {
const needScrollToTop = page === currentPrimaryPage
const exists = primaryPages.find((p) => p.name === page)
if (!exists) {
setPrimaryPages((prev) => [...prev, { name: page, element: PRIMARY_PAGE_MAP[page] }])
}
setCurrentPrimaryPage(page)
if (needScrollToTop) {
PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop()
}
if (isSmallScreen) {
clearSecondaryPages()
}