Skip to content

Fix(editor): arrow keys navigate the @, / and [[ menus again - #707

Open
ArditZubaku wants to merge 4 commits into
ZenNotes:mainfrom
ArditZubaku:fix/completion-arrow-keys
Open

Fix(editor): arrow keys navigate the @, / and [[ menus again#707
ArditZubaku wants to merge 4 commits into
ZenNotes:mainfrom
ArditZubaku:fix/completion-arrow-keys

Conversation

@ArditZubaku

@ArditZubaku ArditZubaku commented Aug 30, 2026

Copy link
Copy Markdown

What

Arrow keys navigate an open completion menu again — the @ date/note suggestions, the / slash menu, the [[ reference picker and the callout [! type picker. Before this, ↑/↓ moved the caret instead, and the caret move closed the menu, so the only way to pick an item was Ctrl+N/Ctrl+P.

Why it broke

autocompletion({ defaultKeymap: false }) skips the stock completion keymap so mac AltGr-style layouts keep their Alt-`/Alt-i characters. The filtered replacement (completionKeymapForEditor) was re-added by spreading it into the editor's general keymap.of([...]).

Upstream mounts that keymap at Prec.highest. The spread put it at default precedence and last in the array — and CodeMirror runs same-key bindings in array order (buildKeymap pushes onto binding.run). So defaultKeymap's ArrowUp/ArrowDown (cursorLineUp/cursorLineDown) ran first, returned true, and the completion never saw the key.

EditorPane and PinnedReferencePane spread it last, so they were broken. QuickCaptureApp and TemplateEditorModal happened to spread it first, so they worked — which is why the behaviour differed between the main editor and the Quick Note window.

The fix

A new completionKeymapExtension mounts the same filtered bindings at Prec.highest, matching what @codemirror/autocomplete does for its own keymap. All four editors mount it next to completionNavKeymap instead of inlining the spread, which removes the ordering trap for future edits.

No behaviour change for the AltGr fix — the two mac chords stay filtered out.

Testing

  • New cm-completion-nav-arrows.test.ts: ↓↓↑ moves the highlighted option, the menu stays open and the caret does not move; with no menu open the arrows fall through to the next binding.
  • Verified the old wiring fails that test and the new wiring passes.
  • npm run typecheck, npm run test:run (1827 passed) and npm run build all pass locally on Node 22.

Before / After

Before — ↓ moves the caret and the @ menu closes.

before.mov

After — ↓/↑ move the highlighted item, the menu stays open.

after.mov

@ArditZubaku
ArditZubaku requested a review from adibhanna as a code owner August 30, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant