-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Various compounding memory leaks in editor #5950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -171,7 +171,7 @@ | |||
"prosemirror-state": "^1.4.3", | |||
"prosemirror-tables": "^1.3.2", | |||
"prosemirror-transform": "^1.7.3", | |||
"prosemirror-view": "^1.31.3", | |||
"prosemirror-view": "^1.32.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get this fix: ProseMirror/prosemirror-view@f25f340
const containerBounds = useComponentSize( | ||
document.body.querySelector("#full-width-container") | ||
); | ||
const documentBounds = props.view.dom.getBoundingClientRect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use cached bounds for document, and one less ResizeObserver
@@ -14,48 +14,44 @@ const defaultRect = { | |||
export default function useComponentSize( | |||
element: HTMLElement | null | |||
): DOMRect | typeof defaultRect { | |||
const [size, setSize] = useState(element?.getBoundingClientRect()); | |||
const [size, setSize] = useState(() => element?.getBoundingClientRect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't calculate getBoundingClientRect
on ever render
); | ||
}); | ||
const sizeObserver = new ResizeObserver(() => { | ||
element?.dispatchEvent(new CustomEvent("resize")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom event allows handling to be in one handleResize
function
@@ -302,6 +302,7 @@ export class Editor extends React.PureComponent< | |||
|
|||
public componentWillUnmount(): void { | |||
window.removeEventListener("theme-changed", this.dispatchThemeChanged); | |||
this.view.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak, not calling destroy
on NodeView
s on unmount
closes #5939
closes #5929