chore(react/collections): highlighting in grid title

This commit is contained in:
Elian Doran 2025-08-30 19:07:06 +03:00
parent 1cee01a22a
commit d52f9f2a92
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -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`}

View File

@ -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) {