From 3c46b485c3fa054ca57eca5a45c670b798da28f0 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Mon, 13 Mar 2023 20:21:08 +0800 Subject: [PATCH] only scroll moves container instead of whole page --- client/src/components/game/GamePage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/components/game/GamePage.tsx b/client/src/components/game/GamePage.tsx index 9e1970e..d14d30c 100644 --- a/client/src/components/game/GamePage.tsx +++ b/client/src/components/game/GamePage.tsx @@ -105,8 +105,9 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { // auto scroll for moves useEffect(() => { const activeMoveEl = document.getElementById("activeNavMove"); - if (!activeMoveEl) return; - activeMoveEl.scrollIntoView({ inline: "nearest", block: "nearest" }); + const moveList = moveListRef.current; + if (!activeMoveEl || !moveList) return; + moveList.scrollTop = activeMoveEl.offsetTop; }); useEffect(() => {