only scroll to on leaderboard page
All checks were successful
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m23s

This commit is contained in:
Lee 2024-10-25 13:38:11 +01:00
parent a9338393f5
commit 59d5cdb2ae

View File

@ -105,14 +105,14 @@ export default function LeaderboardScores({
* scores when new scores are loaded.
*/
useEffect(() => {
if (topOfScoresRef.current && shouldFetch) {
if (topOfScoresRef.current && shouldFetch && isLeaderboardPage) {
const topOfScoresPosition = topOfScoresRef.current.getBoundingClientRect().top + window.scrollY;
window.scrollTo({
top: topOfScoresPosition - 75, // Navbar height (plus some padding)
behavior: "smooth",
});
}
}, [currentPage, topOfScoresRef, shouldFetch]);
}, [currentPage, topOfScoresRef, shouldFetch, isLeaderboardPage]);
useEffect(() => {
if (disableUrlChanging) {