Skip to content

Commit 1372438

Browse files
committed
🐛(frontend) fix memory leak in Interlinking
When doing collaborative editing, doc?.title might be out of sync for other users when updated by another user. This causes the useEffect to run repeatedly, causing an infinite loop of updates. We now trigger the effect only when doc?.title changes, not when the customInlineContent changes.
1 parent c5d5d3d commit 1372438

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to
2626
- ♿(frontend) remove empty alt on logo due to Axe a11y error #1516
2727
- 🐛(backend) fix s3 version_id validation
2828
- 🐛(frontend) retry check media status after page reload #1555
29+
- 🐛(frontend) fix Interlinking memory leak #1560
2930

3031
## [3.8.2] - 2025-10-17
3132

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec(
2929
render: ({ inlineContent, updateInlineContent }) => {
3030
const { data: doc } = useDoc({ id: inlineContent.props.docId });
3131

32+
/**
33+
* Update the content title if the referenced doc title changes
34+
*/
3235
useEffect(() => {
3336
if (doc?.title && doc.title !== inlineContent.props.title) {
3437
updateInlineContent({
@@ -39,7 +42,15 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec(
3942
},
4043
});
4144
}
42-
}, [inlineContent.props, doc?.title, updateInlineContent]);
45+
46+
/**
47+
* ⚠️ When doing collaborative editing, doc?.title might be out of sync
48+
* causing an infinite loop of updates.
49+
* To prevent this, we only run this effect when doc?.title changes,
50+
* not when inlineContent.props.title changes.
51+
*/
52+
// eslint-disable-next-line react-hooks/exhaustive-deps
53+
}, [doc?.title]);
4354

4455
return <LinkSelected {...inlineContent.props} />;
4556
},

0 commit comments

Comments
 (0)