fix(vue-3): solve BubbleMenu v-if remount crash and preserve attribut…#7717
Open
emrullahtastan wants to merge 2 commits intoueberdosis:mainfrom
Open
fix(vue-3): solve BubbleMenu v-if remount crash and preserve attribut…#7717emrullahtastan wants to merge 2 commits intoueberdosis:mainfrom
emrullahtastan wants to merge 2 commits intoueberdosis:mainfrom
Conversation
🦋 Changeset detectedLatest commit: f191bc2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 72 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…e forwarding
Changes Overview
This PR fixes a critical bug where the Vue 3 BubbleMenu component crashes and stops responding to editor events when toggled via v-if. The fix restores the Teleport and imperative element creation approach while maintaining reactive attribute forwarding.
Implementation Approach
The issue was caused by el.remove() being called on a Vue-managed node, which corrupted Vue's virtual DOM reconciliation on subsequent renders.
The new approach:
Imperative Element: Created via document.createElement('div') to keep it outside Vue's VDOM management.
Reactive Attribute Sync: Uses watchEffect to manually but reactively sync attributes (class, style, data-*) from the component to the imperative element, preserving the fix from PR #7101.
Teleport: Renders slot content into the plugin-managed element, matching the successful pattern used in the React implementation.
Testing Done
Manual verification using the Tiptap Vue BubbleMenu demo.
Verified that toggling the menu with v-if multiple times no longer causes crashes.
Verified that the menu remains functional (shows/hides/positions correctly) after multiple remounts.
Verified that no console errors (TypeError) occur during unmount or remount.
Verified that custom classes applied to the component are correctly forwarded to the DOM element.
Verification Steps
Open the Vue BubbleMenu demo.
Toggle the menu component visibility (using a v-if controller if available, or the provided Toggle button).
Select text in the editor after remounting.
Observe that the BubbleMenu appears correctly without errors.
Additional Notes
This aligns the Vue 3 implementation with the React implementation's architecture (which also uses an imperative element and a portal/teleport).
Checklist
Related Issues
Fixes #7685