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
style(autocomplete): keep a long path on the title's line, cut at its start
Elian Doran2eb31dc559d4
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.css b/apps/client/src/widgets/react/NoteAutocomplete.cssindex ccfb3d90c3..0a9423295f 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.css+++ b/apps/client/src/widgets/react/NoteAutocomplete.css@@ -52,15 +52,20 @@min-width: 0;}+ /* The icon stands beside the title's line, not in the middle of a row its badges make taller. */+ > span:not([class]) {+ align-items: baseline;+ }+/*- * The title, then the path to the note at the end of the line, as the search results' cards set- * them. A path with no room beside the title moves under it rather than squeezing it.+ * The title, then the path to the note at the end of the same line, as the search results' cards+ * set them. Short of room, the path gives way four times as fast as the title, which wraps within+ * what is left, and the path is cut short.*/.note-suggestion-header {display: flex;- flex-wrap: wrap;align-items: baseline;- gap: 0 12px;+ gap: 12px;}.search-result-title {@@ -69,8 +74,8 @@}.note-suggestion-path {- flex: 0 1 auto;- min-width: 0;+ flex: 0 4 auto;+ min-width: min(25%, 8em);margin-inline-start: auto;overflow: hidden;text-overflow: ellipsis;@@ -79,6 +84,25 @@color: var(--muted-text-color);}+ /*+ * Cut at its start rather than its end, so the parents nearest the note stay in view: laid out+ * right to left, the overflow and its ellipsis fall on the left, while the isolated text inside+ * keeps its own order. Right-to-left interfaces keep the cut at the end.+ */+ body:not([dir=rtl]) & .note-suggestion-path {+ direction: rtl;+ /* Logical margins follow the box's own direction, so its inline end is the line's left. */+ margin-inline: 0 auto;+ /* A short path in a box held wider by its minimum ends at the right, against the menu's+ inherited `text-align: left`. */+ text-align: right;++ > span {+ direction: ltr;+ unicode-bidi: isolate;+ }+ }+.note-suggestion-description {display: block;font-size: small;diff --git a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsxindex d71897a29f..772444fd3f 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx+++ b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx@@ -244,7 +244,8 @@ describe("NoteAutocomplete's suggestion list", () => {const [ beta, alpha ] = rows();expect(beta.querySelector(".search-result-title")?.innerHTML).toBe("<b>Be</b>ta");- expect(beta.querySelector(".note-suggestion-path")?.innerHTML).toBe("X");+ // Wrapped, so a path too long for the row can be cut at its start, keeping the nearest parents.+ expect(beta.querySelector(".note-suggestion-path > span")?.innerHTML).toBe("X");// A top-level note has no path to show.expect(alpha.querySelector(".note-suggestion-path")).toBeNull();const create = allRows().find((row) => row.querySelector(".bx-plus"));diff --git a/apps/client/src/widgets/react/NoteAutocomplete.tsx b/apps/client/src/widgets/react/NoteAutocomplete.tsxindex bfa5633a24..7e63a4810b 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.tsx+++ b/apps/client/src/widgets/react/NoteAutocomplete.tsx@@ -531,7 +531,7 @@ function NoteSuggestionMenuItemContent({ suggestion }: { suggestion: Suggestion<div className="note-suggestion-text"><div className="note-suggestion-header"><RawHtml className="search-result-title" html={title} />- {parentPath && <RawHtml className="note-suggestion-path" html={parentPath} />}+ {parentPath && <span className="note-suggestion-path"><RawHtml html={parentPath} /></span>}</div>{isCommand? suggestion.commandDescription && (