fix(collections/list): children are displayed twice for empty notes (closes #7301)

This commit is contained in:
Elian Doran
2025-10-13 13:12:00 +03:00
parent 6d5ff42225
commit 1d95205503
2 changed files with 16 additions and 7 deletions

View File

@@ -79,7 +79,7 @@ function ListNoteCard({ note, parentNote, expand, highlightedTokens }: { note: F
</h5>
{isExpanded && <>
<NoteContent note={note} highlightedTokens={highlightedTokens} />
<NoteContent note={note} highlightedTokens={highlightedTokens} noChildrenList />
<NoteChildren note={note} parentNote={parentNote} highlightedTokens={highlightedTokens} />
</>}
</div>
@@ -110,7 +110,11 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa
<span ref={titleRef} className="note-book-title">{noteTitle}</span>
<NoteAttributes note={note} />
</h5>
<NoteContent note={note} trim highlightedTokens={highlightedTokens} />
<NoteContent
note={note}
trim
highlightedTokens={highlightedTokens}
/>
</div>
)
}
@@ -126,12 +130,15 @@ function NoteAttributes({ note }: { note: FNote }) {
return <span className="note-list-attributes" ref={ref} />
}
function NoteContent({ note, trim, highlightedTokens }: { note: FNote, trim?: boolean, highlightedTokens }) {
function NoteContent({ note, trim, noChildrenList, highlightedTokens }: { note: FNote, trim?: boolean, noChildrenList?: boolean, highlightedTokens: string[] | null | undefined }) {
const contentRef = useRef<HTMLDivElement>(null);
const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
useEffect(() => {
content_renderer.getRenderedContent(note, { trim })
content_renderer.getRenderedContent(note, {
trim,
noChildrenList
})
.then(({ $renderedContent, type }) => {
if (!contentRef.current) return;
contentRef.current.replaceChildren(...$renderedContent);