Skip to content

[lexical-react] Bug Fix: Don't auto-dispose editor from LexicalExtensionEditorComposer#8377

Merged
etrepum merged 1 commit into
facebook:mainfrom
etrepum:claude/lexical-editor-composer-fixes-W3GZI
Apr 20, 2026
Merged

[lexical-react] Bug Fix: Don't auto-dispose editor from LexicalExtensionEditorComposer#8377
etrepum merged 1 commit into
facebook:mainfrom
etrepum:claude/lexical-editor-composer-fixes-W3GZI

Conversation

@etrepum

@etrepum etrepum commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

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 LexicalEditorWithDispose contract (the caller built it, the caller disposes it). API docs now make this explicit.

Extracted from #8373

Test Plan

Added unit 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)

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.

…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
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 20, 2026
@vercel

vercel Bot commented Apr 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 20, 2026 3:51pm
lexical-playground Ready Ready Preview, Comment Apr 20, 2026 3:51pm

Request Review

@etrepum etrepum added this pull request to the merge queue Apr 20, 2026
Merged via the queue into facebook:main with commit 3417e37 Apr 20, 2026
45 checks passed
@etrepum etrepum deleted the claude/lexical-editor-composer-fixes-W3GZI branch April 20, 2026 19:04
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>
@etrepum etrepum mentioned this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants