Repository navigation
[lexical] Bug Fix: Avoid read-only warnings for commit-time focus commands - #9230
Merged
etrepum merged 2 commits intoSep 24, 2026
Merged
Conversation
…mands ## Description DOM selection synchronization can synchronously dispatch FOCUS_COMMAND while the committing editor state is frozen. updateEditorSync currently warns even when application code has not entered a read context. Suppress the development warning for the commit's implicit read-only context. Explicit reads still warn, including reads entered by application callbacks during a commit. Command listeners continue to run in a fresh writable update with the existing synchronous dispatch timing. Add browser regressions for editor.focus(), selecting into an unfocused editor, and refocusing an existing selection, with both mutating and non-mutating listeners. Also cover an explicit read entered from a native focus callback during commit. Closes meta#9221 ## Test plan ### Before On main at 6fdbffa, with the new tests: `pnpm run test-browser packages/lexical/src/__tests__/browser/Issue9221FocusReadOnlyWarning.test.ts` ```text AssertionError: expected "Mock" to not be called at all, but actually been called 1 times Test Files 1 failed (1) Tests 6 failed | 1 passed (7) ``` ### After The same browser command passes separately with VITEST_BROWSER set to chromium, firefox, and webkit (21 passing cases total): ```text Test Files 1 passed (1) Tests 7 passed (7) ``` Firefox used MOZ_DISABLE_CONTENT_SANDBOX=1. WebKit used locally extracted liblzo2/libGLESv2 libraries via LD_LIBRARY_PATH and PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=1 because its ldconfig-based check does not detect the locally supplied libGLESv2. All browsers ran on Linux; macOS and Windows were not exercised. `pnpm run test-unit packages/lexical/src/__tests__/unit/LexicalEditor.test.tsx packages/lexical/src/__tests__/unit/LexicalEditorListener.test.ts` ```text Test Files 2 passed (2) Tests 103 passed (103) ``` `pnpm run tsc`, ESLint on the changed files, and `git diff --check` exit 0. Prettier on the changed files: ```text Checking formatting... All matched files use Prettier code style! ``` The supplemental `pnpm exec tsc --noEmit -p tsconfig.test.json` exits 2 with seven errors in unchanged benchmark files (none in the new test), including: ```text packages/lexical/src/__bench__/dom/editorCycle.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'? packages/lexical/src/__bench__/dom/editorOperations.bench.ts(136,15): error TS2740: Type 'LexicalNode' is missing the following properties from type 'ParagraphNode': extractWithChild, insertNewAfter, collapseAtStart, __first, and 57 more. ```
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
September 24, 2026 19:53
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
September 24, 2026 19:53
zurfyx
approved these changes
Sep 24, 2026
Merged
piotrlewalski
added a commit
to piotrlewalski/remdo
that referenced
this pull request
Oct 13, 2026
meta/lexical#9230 (c23a367) fixed the commit-time updateEditorSync warning after 0.51.0 shipped. Apply its condition, which still warns inside an explicit editor.read(), and track dropping the patch on the first release that contains it instead of the upstream-report backlog item. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This branch was successfully deployed
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
DOM selection synchronization can synchronously dispatch
FOCUS_COMMANDwhile the committing editor state is frozen.updateEditorSynccurrently warns even when application code has not entered a read context.Suppress the development warning for the commit's implicit read-only context. Explicit reads still warn, including reads entered by application callbacks during a commit. Command listeners continue to run in a fresh writable update with the existing synchronous dispatch timing.
Add browser regressions for
editor.focus(), selecting into an unfocused editor, and refocusing an existing selection, with both mutating and non-mutating listeners. Also cover an explicit read entered from a native focus callback during commit.Closes #9221
Test plan
New browser test with a mock to track that the warning is not issued during focus events fired synchronously while committing an update.