Skip to content

Commit

Permalink
Automatically trigger autocomplete on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
SiriusXT committed Oct 30, 2024
1 parent acf37f9 commit 227193a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/public/app/services/note_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ function initNoteAutocomplete($el, options) {
// clear any event listener added in previous invocation of this function
$el.off('autocomplete:noteselected');

// Automatically trigger autocomplete on focus, which can achieve:
// 1. Automatically display suggestions when $el is focused, without needing to input any text.
// 2. Automatically show recent notes when creating a new tab.
$el.on('focus', () => {
// simulate pressing down arrow to trigger autocomplete
const e = $.Event('keydown');
e.which = 40; // arrow down
$el.trigger(e);
});

return $el;
}

Expand Down
1 change: 1 addition & 0 deletions trilium-ckeditor5
Submodule trilium-ckeditor5 added at db9c08

0 comments on commit 227193a

Please sign in to comment.