diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c1913e..efc2c732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to - ♿(frontend) remove empty alt on logo due to Axe a11y error #1516 - 🐛(backend) fix s3 version_id validation - 🐛(frontend) retry check media status after page reload #1555 +- 🐛(frontend) fix Interlinking memory leak #1560 ## [3.8.2] - 2025-10-17 diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx index 8f5d30a3..769d6c15 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx @@ -29,6 +29,9 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec( render: ({ inlineContent, updateInlineContent }) => { const { data: doc } = useDoc({ id: inlineContent.props.docId }); + /** + * Update the content title if the referenced doc title changes + */ useEffect(() => { if (doc?.title && doc.title !== inlineContent.props.title) { updateInlineContent({ @@ -39,7 +42,15 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec( }, }); } - }, [inlineContent.props, doc?.title, updateInlineContent]); + + /** + * ⚠️ When doing collaborative editing, doc?.title might be out of sync + * causing an infinite loop of updates. + * To prevent this, we only run this effect when doc?.title changes, + * not when inlineContent.props.title changes. + */ + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [doc?.title]); return ; },