-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Prevent Vue 2 EditorContent components from destroying in-use Editors #7313
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
base: develop
Are you sure you want to change the base?
Conversation
…es currently in use by other EditorContent components. Without checking if this EditorContent instance is currently assigned to the `contentComponent` property, it's possible for the EditorContent instance to destroy an Editor that is in use by another EditorContent instance. Before destroying the editor's view, it should make sure that it is the last EditorContent to use the editor. I've tested the change myself and it seems to be fine. In my case, I have a text editor that I want to quickly move from one component to another. Without this, the first component ends up destroying the text editor after it's already been put to use by the second component. With this, the second component is allowed to take the Editor from the first component without the second component destroying it on them.
|
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull request overview
This PR fixes a race condition in the Vue 2 EditorContent component where a component instance could incorrectly destroy an Editor's view that has been transferred to and is actively being used by another EditorContent instance. The fix adds a simple ownership check (editor.contentComponent !== this) before performing cleanup operations in the beforeDestroy lifecycle hook.
Key Changes:
- Added ownership verification to prevent premature editor destruction when an editor is transferred between EditorContent components
- Ensures that only the current owner of an editor can perform cleanup operations on it
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { editor } = this | ||
|
|
||
| if (!editor) { | ||
| if (!editor || editor.contentComponent !== this) { |
Copilot
AI
Dec 6, 2025
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.
A changeset is required for this PR as it fixes a user-facing bug where EditorContent components could incorrectly destroy editors that are in use by other components. Please run pnpm changeset to create one. The changeset should be a patch version bump and describe the fix: preventing Vue 2 EditorContent from destroying editors that have been transferred to other EditorContent instances.
Changes Overview
Without checking if this EditorContent instance is currently assigned to the
contentComponentproperty, it's possible for the EditorContent instance to destroy an Editor that is in use by another EditorContent instance. Before destroying the editor's view, it should make sure that it is the last EditorContent to use the editor.Implementation Approach
It's just a single line change in a destruction function.
Testing Done
I've tested the change myself and it seems to be fine. In my case, I have a text editor that I want to quickly move from one component to another. Without this, the first component ends up destroying the text editor after it's already been put to use by the second component. With this, the second component is allowed to take the Editor from the first component without the second component destroying it on them.
Verification Steps
Checklist