From c51c301fdff91790e80de7f7431a596732780fb5 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Fri, 6 Mar 2020 19:20:52 +0100 Subject: [PATCH] Fix scrolling to game beginning --- client/src/components/MoveList.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 228971a9..43570984 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -108,9 +108,13 @@ export default { if (window.innerWidth <= 767) return; //scrolling would hide chessboard // $nextTick to wait for table > tr to be rendered this.$nextTick(() => { - let curMove = document.querySelector(".td.highlight-lm"); - if (curMove) { - curMove.scrollIntoView({ + let curLine = document.querySelector(".td.highlight-lm"); + if (!!curLine) curLine = curLine.parentNode; + if (!curLine && this.moves.length > 0) + // Cursor is before game beginning, and some moves were made: + curLine = document.querySelector(".moves-list .tr:first-child") + if (!!curLine) { + curLine.scrollIntoView({ behavior: "auto", block: "nearest" }); -- 2.44.0