[lexical-react] Bug Fix: Don't auto-dispose editor from LexicalExtensionEditorComposer#8377
Merged
etrepum merged 1 commit intoApr 20, 2026
Conversation
…ionEditorComposer
LexicalExtensionEditorComposer previously called initialEditor.dispose()
on unmount, which tears down the editor's extension registrations
(commands, transforms, listeners). For stand-alone editors the caller
built just for the composer this is fine, but for nested editors whose
lifetime is owned by a parent node (e.g. the image caption editor stored
on ImageNode.__caption) the editor is reused across mount cycles.
After the first unmount, the nested editor had no command handlers
registered, so beforeinput events reached Lexical but produced no text
insertion — typing appeared to do nothing.
Remove the auto-dispose effect. The editor's lifetime is now always the
caller's responsibility, which matches the `LexicalEditorWithDispose`
contract (the caller built it, the caller disposes it). Update the
JSDoc on `initialEditor` to make the ownership explicit.
Also add tests that verify:
- editor.dispatchCommand still works after the composer unmounts
- the composer can be unmounted and remounted with the same editor
instance (the caption open/close/open reproduction)
https://claude.ai/code/session_01RUXZGGxJB2neUJvwpH1W6Z
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zurfyx
approved these changes
Apr 20, 2026
levensta
pushed a commit
to levensta/lexical
that referenced
this pull request
Apr 22, 2026
…ionEditorComposer (facebook#8377) Co-authored-by: Claude <noreply@anthropic.com>
Merged
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.
Description
LexicalExtensionEditorComposer previously incorrectly called initialEditor.dispose() on unmount, which tears down the editor's extension registrations (commands, transforms, listeners). The editor's lifetime is now explicitly the caller's responsibility, which matches the
LexicalEditorWithDisposecontract (the caller built it, the caller disposes it). API docs now make this explicit.Extracted from #8373
Test Plan
Added unit tests that verify:
Before
Opening the caption editor, closing it (while empty, by focusing the parent editor), and then re-opening it would result in a non-functioning caption editor. After the first unmount, the nested editor had no command handlers registered, so beforeinput events reached Lexical but produced no text insertion.
After
Caption editor works fine across mount cycles.