Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/collections): highlighting in grid title

Elian Dorand52f9f2a9279
diff --git a/apps/client/src/widgets/collections/legacy/ListView.tsx b/apps/client/src/widgets/collections/legacy/ListView.tsx
index c25f4ac554..eb3ea1de0d 100644
--- a/apps/client/src/widgets/collections/legacy/ListView.tsx
+++ b/apps/client/src/widgets/collections/legacy/ListView.tsx
@@ -87,11 +87,14 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa
const titleRef = useRef<HTMLSpanElement>(null);
const [ noteTitle, setNoteTitle ] = useState<string>();
const notePath = getNotePath(parentNote, note);
+ const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
useEffect(() => {
tree.getNoteTitle(note.noteId, parentNote.noteId).then(setNoteTitle);
}, [ note ]);
+ useEffect(() => highlightSearch(titleRef.current), [ noteTitle, highlightedTokens ]);
+
return (
<div
className={`note-book-card no-tooltip-preview block-link`}
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index b4148197d7..4a9f24cebd 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -558,7 +558,7 @@ export function useImperativeSearchHighlighlighting(highlightedTokens: string[]
return new RegExp(regex, "gi")
}, [ highlightedTokens ]);
- return (el: HTMLElement) => {
+ return (el: HTMLElement | null | undefined) => {
if (!el || !highlightRegex) return;
if (!mark.current) {