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 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 4.6 committed 2026-08-01 20:28:10 -04:00
1 parent 747cc76be6
commit 2a21045e70
1 file changed
+10 -1
+10 -1
View File
@@ -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) {