[lexical] Bug Fix: Workaround for synchronous firefox focus edge case behavior#8356
Merged
etrepum merged 1 commit intofacebook:mainfrom Apr 15, 2026
Merged
Conversation
jsdom's HTMLElement.contentEditable property doesn't synchronize with the 'contenteditable' DOM attribute. This causes test snapshot mismatches where contenteditable="false" on decorator nodes was invisible. Patch the property globally in vitest.setup.mts to delegate to getAttribute/setAttribute matching real browser behavior, and update all affected test expectations. Also fix a bug where $commitPendingUpdates would silently discard deferred callbacks when pendingEditorState was null. This happens in Firefox when editor.focus() runs via the inline updateEditorSync path (activeEditor === editor): the $onUpdate callback is added to _deferred but no new pending state or microtask is created. Add a unit test that reproduces this scenario using AutoFocusExtension with setRootElement inside editor.update(). https://claude.ai/code/session_015cUyLPX8XvNFjAJhUwyoS6
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zurfyx
approved these changes
Apr 15, 2026
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
Workaround a bug where
$commitPendingUpdateswould silently discard deferred callbacks whenpendingEditorStatewas null. This happens in Firefox wheneditor.focus()runs via the inline updateEditorSync path (activeEditor === editor): the$onUpdatecallback is added to_deferredbut no new pending state or microtask is created. Add a unit test that reproduces this scenario usingAutoFocusExtensionwithsetRootElementinsideeditor.update().I think there's a better fix, but unblocks other work.
Test plan
New unit test to cover this edge case
jsdom's HTMLElement.contentEditable property doesn't synchronize with the 'contenteditable' DOM attribute. This causes test snapshot mismatches where contenteditable="false" on decorator nodes was invisible. Patch the property globally in vitest.setup.mts to delegate to getAttribute/setAttribute matching real browser behavior, and update all affected test expectations.