fix: prevent flicker of top tabs on back navigation

This commit is contained in:
codytseng 2025-08-07 09:46:17 +08:00
parent 2f4f4fffcf
commit 3b3a3f41c3
2 changed files with 5 additions and 11 deletions

View file

@ -31,7 +31,6 @@ export function DeepBrowsingProvider({
const [lastScrollTop, setLastScrollTop] = useState(lastScrollTopRef.current)
useEffect(() => {
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])