Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(jump-to-note): keep the footer in place while nothing is searched
Elian Doran704c8fce03f7
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.css b/apps/client/src/widgets/react/NoteAutocomplete.cssindex 2b170dc24a..d3649d9c06 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.css+++ b/apps/client/src/widgets/react/NoteAutocomplete.css@@ -121,6 +121,11 @@.show-in-full-search {margin-inline-start: auto;}++ /* Hidden in place, so the footer keeps its height with only the shortcut hints button left. */+ &.nothing-to-search :is(.switch-widget, .show-in-full-search) {+ visibility: hidden;+ }}/*diff --git a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsxindex 61c88d6253..5aefa5360f 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx+++ b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx@@ -810,6 +810,17 @@ describe("NoteAutocomplete's suggestion list", () => {await act(async () => { footer?.click(); });expect(triggerCommand).toHaveBeenCalledWith("searchNotes", { searchString: "alp" });expect(onChange).toHaveBeenLastCalledWith({ action: "search-notes", noteTitle: "alp" });++ // The recent notes keep the footer, so the list does not move, and its key hints; the+ // searches are hidden, with nothing to search for.+ await type(input, " ");+ const footerBar = host.querySelector(".note-suggestion-footer");+ expect(footerBar?.classList.contains("nothing-to-search")).toBe(true);+ expect(footerBar?.querySelector(".shortcut-hint-button")).not.toBeNull();+ await press(input, "Enter", { shiftKey: true });+ expect(contentsSwitch()?.checked).toBe(false);+ await type(input, "al");+ expect(footerBar?.classList.contains("nothing-to-search")).toBe(false);host.remove();// A dropdown keeps its content search row and has no footer.diff --git a/apps/client/src/widgets/react/NoteAutocomplete.tsx b/apps/client/src/widgets/react/NoteAutocomplete.tsxindex 8d632be704..162f7e3512 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.tsx+++ b/apps/client/src/widgets/react/NoteAutocomplete.tsx@@ -202,6 +202,8 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,*/function fullTextSearch() {if (isContained) {+ // As the footer's switch, which is hidden for a query naming no notes.+ if (!canSearchFor(value)) return;setIncludeContents((include) => !include);autocomplete.open();inputRef.current?.focus();@@ -259,6 +261,7 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,}, [ text, noteId ]);const anchor = anchorRef?.current ?? groupRef.current;+ const showsList = autocomplete.isShown || (autocomplete.isOpen && isSearchingFullText);const showButtons = !opts?.hideAllButtons;const showGoToButton = showButtons && !opts?.hideGoToSelectedNoteButton;@@ -353,43 +356,42 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,/></>}- {(autocomplete.isShown || (autocomplete.isOpen && isSearchingFullText)) && (container- ? container.current && createPortal(<>- <NoteSuggestionMenu+ {container+ ? autocomplete.isOpen && container.current && createPortal(<>+ {showsList && <NoteSuggestionMenuautocomplete={autocomplete}searchingFor={isSearchingFullText ? value : undefined}// The popup's rows, in the host's panel. Faded at an edge only where the host// sets `--scroll-fade-top` or `--scroll-fade-bottom`.className="note-autocomplete-menu note-suggestion-list tn-menu-keyboard scroll-edge-fade"- />- {canSearchFor(value) && (- <div- className="note-suggestion-footer"- // Keeps the focus in the field, as the rows do.- onMouseDown={(e) => e.preventDefault()}- >- {!cachedIsMobile && (- <OverlayControlGroup>- <ShortcutHintOverlayButton />- </OverlayControlGroup>- )}- <FormToggle- switchOnName={t("note_autocomplete.include-contents")}- switchOffName={t("note_autocomplete.include-contents")}- currentValue={includeContents}- onChange={fullTextSearch}- />- {allowJumpToSearchNotes && <Button- className="show-in-full-search"- kind="lowProfile"- size="small"- text={t("quick-search.show-in-full-search")}- onClick={() => showInFullSearch(value.trim())}- />}- </div>- )}+ />}+ {/* Kept for any query, so the list does not move as the searches come and go. */}+ <div+ className={clsx("note-suggestion-footer", !canSearchFor(value) && "nothing-to-search")}+ // Keeps the focus in the field, as the rows do.+ onMouseDown={(e) => e.preventDefault()}+ >+ {!cachedIsMobile && (+ <OverlayControlGroup>+ <ShortcutHintOverlayButton />+ </OverlayControlGroup>+ )}+ <FormToggle+ switchOnName={t("note_autocomplete.include-contents")}+ switchOffName={t("note_autocomplete.include-contents")}+ currentValue={includeContents}+ onChange={fullTextSearch}+ />+ {allowJumpToSearchNotes && <Button+ className="show-in-full-search"+ kind="lowProfile"+ size="small"+ text={t("quick-search.show-in-full-search")}+ onClick={() => showInFullSearch(value.trim())}+ />}+ </div></>, container.current)- : anchor && (+ : showsList && anchor && (<Popupanchor={anchor}// Rendered in the field's modal so the list stacks above it: the note picker@@ -409,7 +411,7 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,className="tn-menu-scroll"/></Popup>- ))}+ )}</div>);}diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.htmlindex ac1e654b2b..8908c1b167 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.html@@ -37,7 +37,8 @@</li><li>When the title search does not find a note, the bar below the resultsoffers two ways to search further. It stays below the list, however far- the results are scrolled.+ the results are scrolled. Both are hidden while the field is empty or lists+ commands.<ul><li>The <em>Include note contents</em> switch searches the content of the notesas well as their titles, and lists what it finds in place of the currentdiff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.md b/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.mdindex 4a34dca22c..1fe9c7f19e 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Jump to & command palette.md@@ -19,7 +19,7 @@ In addition to searching for notes, it is also possible to search for commands.* If the note doesn't exist, it's possible to create it by typing the desired note title and selecting one of two options:* _Create note_ places it in the <a class="reference-link" href="../Notes/Note%20Inbox.md">Note Inbox</a>: the note labelled `#inbox`, today's <a class="reference-link" href="../../Advanced%20Usage/Advanced%20Showcases/Day%20Notes.md">Day Notes</a> if there is none, or the top level if there is no journal either. While hoisted into a <a class="reference-link" href="Workspaces.md">Workspaces</a>, the workspace's own inbox is used, then today's day note if the workspace has a `#workspaceCalendarRoot`, otherwise the workspace root itself. The option names the destination, so it is always visible before the note is created.* _Create child note_ places it under the note that is currently open.-* When the title search does not find a note, the bar below the results offers two ways to search further. It stays below the list, however far the results are scrolled.+* When the title search does not find a note, the bar below the results offers two ways to search further. It stays below the list, however far the results are scrolled. Both are hidden while the field is empty or lists commands.* The _Include note contents_ switch searches the content of the notes as well as their titles, and lists what it finds in place of the current results, without leaving the dialog. It stays on while the query changes, until it is switched off. Press <kbd>Shift</kbd>+<kbd>Enter</kbd> to switch it from the keyboard.* _Show in full search_ opens the query in the full <a class="reference-link" href="Search.md">Search</a>, in a new tab, where its options can refine it. Press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to run it from the keyboard.* To see the keys the results answer to, click the <kbd>?</kbd> button below the results, or press <kbd>Alt</kbd>+<kbd>F1</kbd> while the search field is focused.