Fix scroll jumping to the top?

This commit is contained in:
Alex Gleason 2024-10-28 10:32:44 -05:00
parent c46d988fd5
commit a331ef7452
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ export const ScrollContext: React.FC<IScrollContext> = ({ shouldUpdateScroll, ch
const prevLocation = usePrevious(location); const prevLocation = usePrevious(location);
useEffect(() => { useEffect(() => {
if (prevLocation && shouldUpdateScroll(prevLocation, location)) { if (prevLocation && (prevLocation.pathname !== location.pathname) && shouldUpdateScroll(prevLocation, location)) {
window.scrollTo(0, 0); window.scrollTo(0, 0);
} }
}, [location, shouldUpdateScroll]); }, [location, shouldUpdateScroll]);