Skip to content

Build your personal knowledge base with Trilium Notes

feat(jump to note): keep the dialog a title navigator

Elian Doranb5b784efb9ed
diff --git a/apps/client/src/services/note_autocomplete.spec.ts b/apps/client/src/services/note_autocomplete.spec.ts
index ddf88ead12..4c71dd4eed 100644
--- a/apps/client/src/services/note_autocomplete.spec.ts
+++ b/apps/client/src/services/note_autocomplete.spec.ts
@@ -337,9 +337,9 @@ describe("autocompleteSource (via dataset)", () => {
expect(html).toContain("#color=red");
});
- it("does not render a content snippet by default, even when the suggestion has one", () => {
- // showContentSnippets defaults to false so compact consumers (link dialogs, relation
- // editors, @-mentions) don't grow an extra line.
+ it("never renders a content snippet, whatever the suggestion carries", () => {
+ // The dropdown lists notes matched by title and attributes, so a body excerpt would
+ // suggest a content match that fast search never made.
const { dataset } = initAndGetSource();
const html = dataset.templates.suggestion({
highlightedNotePathTitle: "T",
@@ -349,22 +349,6 @@ describe("autocompleteSource (via dataset)", () => {
expect(html).not.toContain("matched");
});
- it("does not render a content snippet when showContentSnippets is set but the suggestion has none", () => {
- const { dataset } = initAndGetSource({ showContentSnippets: true });
- const html = dataset.templates.suggestion({ highlightedNotePathTitle: "T" });
- expect(html).not.toContain("search-result-content");
- });
-
- it("renders the content snippet when showContentSnippets is enabled (jump-to-note dialog)", () => {
- const { dataset } = initAndGetSource({ showContentSnippets: true });
- const html = dataset.templates.suggestion({
- highlightedNotePathTitle: "T",
- highlightedContentSnippet: "some <b>matched</b> content"
- });
- expect(html).toContain("search-result-content");
- expect(html).toContain("some <b>matched</b> content");
- });
-
it("renders search-notes, create-note and external-link suggestion icons/classes", () => {
const { dataset } = initAndGetSource();
expect(dataset.templates.suggestion({ action: "search-notes", highlightedNotePathTitle: "S" }))
@@ -552,7 +536,7 @@ describe("initNoteAutocomplete wiring", () => {
// clear button -> autocomplete("val", "") + change trigger. Also re-triggers "input" so
// consumers tracking the live query (e.g. jump_to_note.tsx's actualText ref) don't go
- // stale when the value is cleared programmatically instead of by typing (#task-7 review).
+ // stale when the value is cleared programmatically instead of by typing.
$group.find(".input-clearer-button").trigger("click");
expect(autocompleteCalls.some((c) => c[0] === "val" && c[1] === "")).toBe(true);
expect(onInput).toHaveBeenCalled();
@@ -842,7 +826,7 @@ describe("public helpers", () => {
noteAutocomplete.setText($el, " hello ");
expect(lastCommandWith("open")).toBe(true);
expect($el.attr("data-note-path")).toBe("");
- // re-triggers "input" so consumers tracking the live query stay in sync (#task-7 review)
+ // re-triggers "input" so consumers tracking the live query stay in sync
expect(onInput).toHaveBeenCalled();
});
diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts
index ed2dfbe3b4..a5f9809cc0 100644
--- a/apps/client/src/services/note_autocomplete.ts
+++ b/apps/client/src/services/note_autocomplete.ts
@@ -40,8 +40,6 @@ export interface Suggestion {
commandShortcut?: string;
attributeSnippet?: string;
highlightedAttributeSnippet?: string;
- contentSnippet?: string;
- highlightedContentSnippet?: string;
}
export interface Options {
@@ -56,12 +54,6 @@ export interface Options {
hideAllButtons?: boolean;
/** If set, enables command palette mode */
isCommandPalette?: boolean;
- /**
- * If set, note suggestions also render their content snippet (below the attribute
- * snippet), matching the quick-search dropdown / search results view. Off by default
- * so compact consumers (link dialogs, relation editors, `@`-mentions) stay unchanged.
- */
- showContentSnippets?: boolean;
}
async function autocompleteSourceForCKEditor(queryText: string) {
@@ -381,10 +373,6 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
html += `<span class="search-result-attributes">${suggestion.highlightedAttributeSnippet}</span>`;
}
- if (options.showContentSnippets && suggestion.highlightedContentSnippet) {
- html += `<span class="search-result-content">${suggestion.highlightedContentSnippet}</span>`;
- }
-
html += `</span>`;
html += `</div>`;
return html;
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 632ce60463..fa5d656408 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -1073,28 +1073,6 @@ table.promoted-attributes-in-tooltip th {
word-wrap: break-word;
}
-.aa-dropdown-menu .aa-suggestion .search-result-content {
- display: block;
- margin-top: 4px;
- font-size: 0.85em;
- color: var(--muted-text-color);
- line-height: 1.3;
- word-wrap: break-word;
-}
-
-.aa-dropdown-menu .aa-suggestion .search-result-content b {
- background: var(--note-list-view-search-result-highlight-background);
- color: var(--note-list-view-search-result-highlight-color);
- font-weight: 600;
- text-decoration: underline;
-}
-
-.aa-dropdown-menu .aa-suggestion .search-result-content b.search-fuzzy-match {
- color: var(--note-list-view-search-result-fuzzy-highlight-color);
- font-weight: 400;
- text-decoration: underline dotted;
-}
-
.aa-dropdown-menu .aa-suggestion p {
padding: 0;
margin: 0;
diff --git a/apps/client/src/widgets/dialogs/jump_to_note.tsx b/apps/client/src/widgets/dialogs/jump_to_note.tsx
index 49e90641e2..29ce394c1a 100644
--- a/apps/client/src/widgets/dialogs/jump_to_note.tsx
+++ b/apps/client/src/widgets/dialogs/jump_to_note.tsx
@@ -5,7 +5,6 @@ import { useRef, useState } from "preact/hooks";
import appContext from "../../components/app_context";
import commandRegistry from "../../services/command_registry";
import { t } from "../../services/i18n";
-import type { ViewScope } from "../../services/link";
import note_autocomplete, { Suggestion } from "../../services/note_autocomplete";
import shortcutService from "../../services/shortcuts";
import Button from "../react/Button";
@@ -50,8 +49,8 @@ export default function JumpToNoteDialogComponent() {
setMode(newMode);
}
- // The "recent-notes" branch above resets the displayed text without firing "input", which
- // is what normally updates this ref, so keep it in sync with what is about to be shown.
+ // `showInFullSearch` reads this ref, so it has to follow the text about to be displayed
+ // rather than keep the previous session's query.
actualText.current = initialText;
setInitialText(initialText);
@@ -69,9 +68,7 @@ export default function JumpToNoteDialogComponent() {
setShown(false);
if (suggestion.notePath) {
- const searchString = !isCommandMode ? actualText.current?.trim() : "";
- const viewScope: ViewScope = searchString ? { searchTerms: [ searchString ] } : {};
- appContext.tabManager.getActiveContext()?.setNote(suggestion.notePath, { viewScope });
+ appContext.tabManager.getActiveContext()?.setNote(suggestion.notePath);
} else if (suggestion.commandId) {
await commandRegistry.executeCommand(suggestion.commandId);
}
@@ -139,8 +136,7 @@ export default function JumpToNoteDialogComponent() {
allowCreatingNotes: true,
hideGoToSelectedNoteButton: true,
allowJumpToSearchNotes: true,
- isCommandPalette: true,
- showContentSnippets: true
+ isCommandPalette: true
}}
onTextChange={(text) => {
actualText.current = text;