From 7c3744a74ae226b30385d4b3fdecbe978424dde5 Mon Sep 17 00:00:00 2001 From: GuillaumeSD Date: Sat, 6 Apr 2024 03:21:39 +0200 Subject: [PATCH] fix : moves panel scroll into view --- .../classificationPanel/movesPanel/index.tsx | 1 + .../classificationPanel/movesPanel/moveItem.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sections/analysis/reviewPanelBody/classificationPanel/movesPanel/index.tsx b/src/sections/analysis/reviewPanelBody/classificationPanel/movesPanel/index.tsx index 1c2db7f..6fb001f 100644 --- a/src/sections/analysis/reviewPanelBody/classificationPanel/movesPanel/index.tsx +++ b/src/sections/analysis/reviewPanelBody/classificationPanel/movesPanel/index.tsx @@ -47,6 +47,7 @@ export default function MovesPanel() { sx={{ scrollbarWidth: "thin", overflowY: "auto" }} maxHeight="100%" xs={6} + id="moves-panel" > {gameMoves?.map((moves, idx) => ( { if (!isCurrentMove) return; const moveItem = document.getElementById(`move-${moveIdx}`); - if (!moveItem || !isInViewport(moveItem)) return; + if (!moveItem) return; + + const movePanel = document.getElementById("moves-panel"); + if (!movePanel || !isInViewport(movePanel)) return; + moveItem.scrollIntoView({ behavior: "smooth", block: "center" }); }, [isCurrentMove, moveIdx]);