Skip to content

Build your personal knowledge base with Trilium Notes

style(text): cap the width of the @ list

Elian Dorand7ee35de8cb0
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.css b/apps/client/src/widgets/react/NoteAutocomplete.css
index 0211c67a89..c12e93ad6f 100644
--- a/apps/client/src/widgets/react/NoteAutocomplete.css
+++ b/apps/client/src/widgets/react/NoteAutocomplete.css
@@ -51,6 +51,14 @@
max-width: calc(100vw - 10px);
}
+/*
+ * The list after an `@` has no field to take its width from, so it grows with its rows. Past this,
+ * a long path or a row of attributes wraps.
+ */
+.note-autocomplete-menu.note-mention-menu {
+ max-width: min(600px, calc(100vw - 10px));
+}
+
.note-autocomplete-menu .dropdown-item {
/* Outranks Bootstrap's `nowrap`, so a long note path wraps within the list's width. */
white-space: normal;
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx
index a499b8021c..a241dbecbf 100644
--- a/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx
+++ b/apps/client/src/widgets/react/NoteAutocomplete.spec.tsx
@@ -1160,6 +1160,8 @@ describe("NoteMentionList", () => {
expect(getNoteSuggestions).toHaveBeenLastCalledWith("al", { allowCreatingNotes: true, limit: 10 });
expect(rows().map((row) => row.querySelector(".search-result-title")?.innerHTML)).toEqual([ "<b>Al</b>pha", "Beta" ]);
expect(rows()[0].querySelector(".tn-icon")?.className).toContain("bx-file");
+ // Capped in width by its own class, as it has no field to take a width from.
+ expect(rows()[0].closest(".tn-popup")?.classList.contains("note-mention-menu")).toBe(true);
await draw("alp");
expect(getNoteSuggestions).toHaveBeenLastCalledWith("alp", { allowCreatingNotes: true, limit: 10 });
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.tsx b/apps/client/src/widgets/react/NoteAutocomplete.tsx
index 35868ca4f7..75fdf66dca 100644
--- a/apps/client/src/widgets/react/NoteAutocomplete.tsx
+++ b/apps/client/src/widgets/react/NoteAutocomplete.tsx
@@ -478,7 +478,7 @@ export function NoteMentionList({ query, anchor, allowCreatingNotes, parentNoteP
useForwardedKeys(autocomplete, handleRef);
return autocomplete.isShown && (
- <NoteSuggestionPopup anchor={anchor} elementRef={elementRef}>
+ <NoteSuggestionPopup anchor={anchor} elementRef={elementRef} className="note-mention-menu">
<NoteSuggestionMenu autocomplete={autocomplete} className="tn-menu-scroll" />
</NoteSuggestionPopup>
);