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
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.tsxindex 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, paconst 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 (<divclassName={`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.tsxindex 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) {