From 2a21045e70fcb415dbcf834efb8083f6639f6be3 Mon Sep 17 00:00:00 2001 From: Nate Emmert Date: Sat, 1 Aug 2026 20:28:10 -0400 Subject: [PATCH] Fix crossword clue scrollIntoView jumping the page Replace scrollIntoView (which escapes to the window when the list isn't tall enough to scroll) with manual scrollTop logic that stays strictly within the clue list container. Co-Authored-By: Claude Sonnet 4.6 --- public/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/app.js b/public/app.js index a09e1c5..4915749 100644 --- a/public/app.js +++ b/public/app.js @@ -1090,7 +1090,16 @@ async function openCrossword(itemId) { } const listEl = dir === 'across' ? acrossListEl : downListEl; const li = listEl.querySelector(`[data-num="${word.num}"]`); - if (li) { li.classList.add('selected-clue'); li.scrollIntoView({ block: 'nearest' }); } + if (li) { + li.classList.add('selected-clue'); + const liTop = li.offsetTop; + const liBottom = liTop + li.offsetHeight; + if (liBottom > listEl.scrollTop + listEl.clientHeight) { + listEl.scrollTop = liBottom - listEl.clientHeight; + } else if (liTop < listEl.scrollTop) { + listEl.scrollTop = liTop; + } + } } function pickWord(key) {