only scroll moves container instead of whole page

This commit is contained in:
Nathaniel Tampus
2023-03-13 20:21:08 +08:00
parent 055cc5781d
commit 3c46b485c3

View File

@@ -105,8 +105,9 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
// auto scroll for moves // auto scroll for moves
useEffect(() => { useEffect(() => {
const activeMoveEl = document.getElementById("activeNavMove"); const activeMoveEl = document.getElementById("activeNavMove");
if (!activeMoveEl) return; const moveList = moveListRef.current;
activeMoveEl.scrollIntoView({ inline: "nearest", block: "nearest" }); if (!activeMoveEl || !moveList) return;
moveList.scrollTop = activeMoveEl.offsetTop;
}); });
useEffect(() => { useEffect(() => {