diff --git a/frontend/src/GameList.tsx b/frontend/src/GameList.tsx index 0cc00df..2e17f9a 100644 --- a/frontend/src/GameList.tsx +++ b/frontend/src/GameList.tsx @@ -8,7 +8,7 @@ import { AddOpinionRequest, RemoveOpinionRequest, } from "../items"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { apiFetch, get_auth_status } from "./api"; import { GameImage } from "./GameImage"; @@ -54,6 +54,17 @@ export function GameList() { }); }, []); + // Scroll to Existing Games section if hash is present + const location = useLocation(); + useEffect(() => { + if (location.hash === "#existing-games") { + const el = document.getElementById("existing-games"); + if (el) { + el.scrollIntoView({ behavior: "smooth" }); + } + } + }, [location]); + useEffect(() => { fetchGames(); }, []); @@ -455,7 +466,7 @@ export function GameList() {