fix(editor): keep focus scopes registered across plugin reconfigurations - #3627
Merged
felipefreitag merged 1 commit intoJul 7, 2026
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 2410fb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
ProseMirror destroys and recreates plugin views on every state reconfiguration, and bubble menus and slash commands register their plugins in mount effects. The FocusScopes plugin view wiped the whole scope registry in destroy(), so right after mount only the editor's own DOM remained registered and clicking any bubble-menu or Inspector control blurred the editor and cleared the selection. The registry now survives reconfigurations; full cleanup runs only when the plugin is removed from the editor state or the editor is destroyed (via the editor 'destroy' event, since plugin views are torn down before isDestroyed flips true). Closes #3603
felipefreitag
force-pushed
the
fix-focus-scope-registry-wipe-on-reconfigure
branch
from
July 6, 2026 20:23
36393f5 to
2410fb1
Compare
felipefreitag
marked this pull request as draft
July 6, 2026 20:30
felipefreitag
marked this pull request as ready for review
July 7, 2026 17:36
dielduarte
approved these changes
Jul 7, 2026
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.
Summary
Fixes bubble menus and the Inspector losing the editor selection on click (#3603).
The
FocusScopesplugin view wiped its entire scope registry indestroy(). ProseMirror destroys and recreates plugin views on every state reconfiguration, and bubble menus and slash commands register their plugins in mount effects — a reconfiguration that fires right after theEditorFocusScoperefs registered the menu/Inspector elements. After mount, only the editor's ownview.domremained registered, so clicking any bubble-menu sub-control or Inspector field was treated as focus leaving the editor: the menu closed, the selection collapsed, and focus went to<body>.Changes
destroy.if (!editor.isDestroyed) returnguard suggested in the issue: ProseMirror destroys plugin views beforedocViewis nulled, soisDestroyedis stillfalseat that point and the guard would make cleanup unreachable (leaking listeners). The editordestroyevent covers real teardown instead.Testing
pnpm vitest run --project unitinpackages/editor→ 496 passed / 1 skipped;tsc --noEmitandbiome checkclean.apps/webfull-email-builder example in a real browser: the node-selector dropdown opens and applies without closing the bubble menu, the Inspector keeps the selection while its inputs are focused, and blur to elements outside all scopes still clears the selection as before.Closes #3603
Summary by cubic
Fixes bubble menus and the Inspector losing the editor selection by keeping focus scopes registered across ProseMirror reconfigurations in
@react-email/editor. Selection now stays while interacting with menu/Inspector controls.destroyevent for teardown; make register/unregister no-ops after cleanup to prevent re-adding scopes.Written for commit 2410fb1. Summary will update on new commits.