Skip to content

[lexical] Bug Fix: Workaround for synchronous firefox focus edge case behavior#8356

Merged
etrepum merged 1 commit intofacebook:mainfrom
etrepum:claude/patch-jsdom-contenteditable-iOU5k
Apr 15, 2026
Merged

[lexical] Bug Fix: Workaround for synchronous firefox focus edge case behavior#8356
etrepum merged 1 commit intofacebook:mainfrom
etrepum:claude/patch-jsdom-contenteditable-iOU5k

Conversation

@etrepum
Copy link
Copy Markdown
Collaborator

@etrepum etrepum commented Apr 14, 2026

Description

Workaround 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().

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.

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
@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 14, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 14, 2026 11:13pm
lexical-playground Ready Ready Preview, Comment Apr 14, 2026 11:13pm

Request Review

@etrepum etrepum added this pull request to the merge queue Apr 15, 2026
Merged via the queue into facebook:main with commit 11bb5e5 Apr 15, 2026
41 of 67 checks passed
@etrepum etrepum deleted the claude/patch-jsdom-contenteditable-iOU5k branch April 19, 2026 02:32
@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