From 3b3a3f41c3af61871bbc7fbd02aea99f4084e235 Mon Sep 17 00:00:00 2001 From: codytseng Date: Thu, 7 Aug 2025 09:46:17 +0800 Subject: [PATCH] fix: prevent flicker of top tabs on back navigation --- src/layouts/PrimaryPageLayout/index.tsx | 4 ++-- src/providers/DeepBrowsingProvider.tsx | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/layouts/PrimaryPageLayout/index.tsx b/src/layouts/PrimaryPageLayout/index.tsx index 15d19ff..a8dd6ee 100644 --- a/src/layouts/PrimaryPageLayout/index.tsx +++ b/src/layouts/PrimaryPageLayout/index.tsx @@ -60,7 +60,7 @@ const PrimaryPageLayout = forwardRef( if (isSmallScreen) { return ( - +
+ { - setDeepBrowsing(false) if (!active) return const handleScroll = () => { @@ -51,16 +50,11 @@ export function DeepBrowsingProvider({ } } - if (!scrollAreaRef) { - window.addEventListener('scroll', handleScroll) - return () => { - window.removeEventListener('scroll', handleScroll) - } - } + const target = scrollAreaRef ? scrollAreaRef.current : window - scrollAreaRef.current?.addEventListener('scroll', handleScroll) + target?.addEventListener('scroll', handleScroll) return () => { - scrollAreaRef.current?.removeEventListener('scroll', handleScroll) + target?.removeEventListener('scroll', handleScroll) } }, [active])