fix(web): auto-scroll and Enter key completion for slash command autocomplete (#475)

- Add scrollIntoView to keep arrow-key-selected item visible in dropdown
- Make Enter complete the first matching command when autocomplete is
  visible, instead of requiring explicit arrow-key navigation first

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
Henry Park
2026-03-02 13:06:55 -08:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 1a26b1e57f
commit 20073ccf57
+4 -1
View File
@@ -359,6 +359,9 @@ function selectSlashItem(cmd) {
function updateSlashHighlight() {
const items = document.querySelectorAll('#slash-autocomplete .slash-ac-item');
items.forEach((el, i) => el.classList.toggle('selected', i === _slashSelected));
if (_slashSelected >= 0 && items[_slashSelected]) {
items[_slashSelected].scrollIntoView({ block: 'nearest' });
}
}
function filterSlashCommands(value) {
@@ -1196,7 +1199,7 @@ chatInput.addEventListener('keydown', (e) => {
updateSlashHighlight();
return;
}
if (e.key === 'Tab' || (e.key === 'Enter' && _slashSelected >= 0)) {
if (e.key === 'Tab' || e.key === 'Enter') {
e.preventDefault();
const pick = _slashSelected >= 0 ? _slashMatches[_slashSelected] : _slashMatches[0];
if (pick) selectSlashItem(pick.cmd);