Autocomplete: ↓ moves into the list (no pre-selection)

Autocomplete: ↓ moves into the list (no pre-selection)

#5 in Riparion/riparion-editor — merged 2026-06-02

What

Refines the [[/ autocomplete keyboard model so the down arrow moves into the dropdown — letting you trigger, navigate, and insert without leaving the keyboard.

Before: the popup opened with item 0 pre-highlighted, so the first ↓ jumped to the second item (felt like it skipped the first). Now:

  • Popup opens with nothing highlighted.
  • First enters the list on the first item; first enters on the last; further ↓/↑ navigate (wrap). While open, arrows belong to the popup, not the textarea caret.
  • Enter/Tab insert only once an item is selected; with nothing selected they fall through to the textarea (a normal newline/tab) — so you must ↓ first. After accept, the popup closes and arrow keys return to normal editing.
  • Esc closes the menu with no insert and restores normal editing.

How

  • Autocomplete::selected is now Option<usize> (None = caret still in the text); selected() and CompletionPopup's selected prop change accordingly.
  • on_input opens/refilters with selected = None; on_keydown is None-aware for ↓/↑/Enter/Tab.

Verification

  • cargo test --no-default-features: 20 passed (pure find_trigger/apply_completion logic unchanged).
  • clippy -D warnings on non-web --all-targets and wasm --features web (incl. the example).

Consumed by riparion-cms via a pin bump.

🤖 Generated with Claude Code

Last updated 2026-06-03