Closed
Description
Affected Packages
extension-bubble-menu
Version(s)
3.0.0-beta.7
Bug Description
I'm creating and destroying bubble menus for my current project, and I've noticed it's trying to run code on destroyed editors, and it consistently increases the more I load up a new editor.
Looking at the code I can see why https://github.com/ueberdosis/tiptap/blob/next/packages/extension-bubble-menu/src/bubble-menu-plugin.ts#L233
The bubble menu resize handler is being added but never removed on plugin removal. To work around it I've extended the class and done the following:
class MyBubbleMenuView extends BubbleMenuView {
constructor(...args) {
const origListener = window.addEventListener;
window.addEventListener = () => {};
super(...args);
window.addEventListener = origListener;
window.addEventListener("resize", this.onResize);
}
onResize = () => {
if (this.resizeDebounceTimer) {
clearTimeout(this.resizeDebounceTimer);
}
this.resizeDebounceTimer = window.setTimeout(() => {
this.updatePosition();
}, this.resizeDelay);
};
destroy() {
super.destroy();
window.removeEventListener("resize", this.onResize);
}
}
Browser Used
Chrome
Code Example URL
No response
Expected Behavior
The resize event should not be called after the plugin is destroyed.
Additional Context (Optional)
No response
Dependency Updates
- Yes, I've updated all my dependencies.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Closed