diff --git a/app/static/js/view-modal.js b/app/static/js/view-modal.js index 16b9ba1..c39d243 100644 --- a/app/static/js/view-modal.js +++ b/app/static/js/view-modal.js @@ -971,6 +971,12 @@ document.addEventListener('DOMContentLoaded', () => { el.classList.toggle('selected', i === index); }); autocompleteSelectedIndex = index; + // Keep the highlighted row in view as the user arrows past the + // visible slice. `block: 'nearest'` is a no-op when already visible, + // and scrolls the minimum distance otherwise. + if (index >= 0 && items[index]) { + items[index].scrollIntoView({ block: 'nearest', inline: 'nearest' }); + } } async function fetchAutocomplete(query) { @@ -1086,6 +1092,9 @@ document.addEventListener('DOMContentLoaded', () => { const items = fandomPickerAutocomplete.querySelectorAll('.tag-autocomplete-item'); items.forEach((el, i) => el.classList.toggle('selected', i === idx)); fandomPickerSelectedIdx = idx; + if (idx >= 0 && items[idx]) { + items[idx].scrollIntoView({ block: 'nearest', inline: 'nearest' }); + } } function pickFandomRow(row) {