Skip to content

fix: show wikilink suggestions in the native aliases editor - #226

Merged
chhoumann merged 2 commits into
masterfrom
fix/aliases-wikilink-suggest
Oct 24, 2026
Merged

chhoumann merged 2 commits into
masterfrom
fix/aliases-wikilink-suggest

Conversation

@chhoumann

@chhoumann chhoumann commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

In the Edit aliases prompt, typing [[ never showed link suggestions. Instead, [[ became its own pill. MetaEdit adds its own [[ suggester to the aliases widget because Obsidian's aliases widget has none.

Cause: NativeWikilinkSuggester fed AbstractInputSuggest through a hidden mirror <input> and moved focus into it on every [[. The pill input lost focus, so Obsidian's multi-select committed [[ as a pill and re-rendered. That re-render removed the mirror, so focus fell to body and no popover opened.

Fix: AbstractInputSuggest accepts a contenteditable div, so the suggester now attaches to the pill input directly and reads the [[query from its text. The mirror input, its focus juggling, and its CSS are gone (net -51 lines).

The E2E test for this path had been skipped since #168, with a note saying synthetic DOM events wedged the obsidian-e2e transport. With the current transport it no longer wedges. It just timed out waiting for suggestions, which was this bug. The test is re-enabled. Its helpers now type the link query after [[, as a user does.

Verification

Obsidian 1.13.7, Linux, isolated obsidian-e2e vault, real keystrokes through CDP Input.insertText / Input.dispatchKeyEvent:

  • On master, typing [[A, B gives pills Alias One, [[ and no suggestions.
  • On this branch, typing [[A, B shows the A, B suggestion. Enter fills [[A, B]], a second Enter commits the pill, and Save writes - "[[A, B]]" to aliases.
  • tests/e2e/native-properties.test.ts (wikilink test included): 6 passed. With master's src/ and styles.css it fails with Timed out waiting for .suggestion-item.
  • pnpm run lint, pnpm run build, pnpm run test (359 passed).

Release impact: user-facing fix, no settings or API changes.


Note

Low Risk
Scoped to aliases wikilink fallback UI and E2E helpers; no auth, data migration, or broad API changes.

Overview
Fixes wikilink autocomplete in the native aliases editor by rewiring NativeWikilinkSuggester so it no longer uses a hidden mirror <input> and focus juggling (which caused [[ to commit as a pill before suggestions could appear).

The suggester now binds AbstractInputSuggest directly to the aliases multi-select contenteditable, derives the query from trailing [[… text in getSuggestions, and applies the chosen link via setValue. NativeWidgetHost teardown calls close() instead of a custom destroy(), and the mirror-input CSS is removed.

The previously skipped E2E native wikilink suggestions test is re-enabled; helpers type [[ plus the query (like a user) instead of only [[ with synthetic input/keyup events.

Reviewed by Cursor Bugbot for commit 4c25d1b. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix wikilink suggestions in the native aliases editor by attaching to the contenteditable div

  • NativeWikilinkSuggester now attaches directly to the contenteditable HTMLDivElement instead of creating and syncing a hidden mirror input; the mirror element, its CSS rule, and the custom destroy method are removed
  • getSuggestions matches the trailing wikilink expression in the full input text and filters paths and aliases case-insensitively; text without a trailing wikilink returns no suggestions
  • acceptSuggestion writes the selected link through AbstractInputSuggest.setValue before restoring focus and dispatching the input event
  • Enables the previously skipped e2e test for wikilink suggestions in text, multitext, and aliases widgets (native-properties.test.ts)
  • Behavioral Change: inputs without a trailing incomplete wikilink no longer produce suggestions

Macroscope summarized a491fd9.

Typing [[ in the Edit aliases prompt moved focus to a hidden mirror input
that fed AbstractInputSuggest. Losing focus made Obsidian's multi-select
commit [[ as its own pill and re-render, so no suggestions ever showed.
AbstractInputSuggest accepts a contenteditable div, so attach it to the
pill input directly and read the [[ query from its text.

Re-enables the skipped native wikilink E2E test. Its helpers now type the
link query after [[, as a user does.
@chhoumann
chhoumann merged commit f2dbd2e into master Oct 24, 2026
10 of 11 checks passed
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