Skip to content

[lexical] Bug Fix: SKIP_DOM_SELECTION_TAG applies to the initial mount - #8951

Closed
LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix-8610-skip-dom-selection
Closed

LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix-8610-skip-dom-selection

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

An update that runs before the editor has a root element — notably an $initialEditorState initializer, or the editorState of an initial config — is reconciled to an EditorState only. The DOM-selection block is never reached and the update tags are cleared at the end of that commit, so by the time setRootElement reconciles that state into the contenteditable there is no SKIP_DOM_SELECTION_TAG left. Initializing content with $insertNodes therefore moved the DOM selection and scrolled the page to the end of the content even though the tag was set.

This remembers the request across the un-mounted commit and re-applies the tag on the first commit that has a root element, so the tag means the same thing during initialization as it does afterwards. The $setSelection(null) workaround keeps working; the tag's doc comment now describes the mount case.

Fixes #8610

An update that runs before the editor has a root element — notably an
`$initialEditorState` initializer, or the `editorState` of an initial config —
is reconciled to an EditorState only. The DOM selection block is never reached
and the update tags are cleared at the end of that commit, so by the time
setRootElement reconciles that state into the contenteditable there is no
SKIP_DOM_SELECTION_TAG left. Initializing content with $insertNodes therefore
moved the DOM selection and scrolled the page to the end of the content even
though the tag was set.

Remember the request across the un-mounted commit and re-apply the tag on the
first commit that has a root element.

Fixes meta#8610
@vercel

vercel Bot commented Aug 7, 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 Aug 7, 2026 10:01am
lexical-playground Ready Ready Preview Aug 7, 2026 10:01am

Request Review

This branch was successfully deployed

2 active deployments
Preview – lexical — 9310e788 Deployed Aug 7, 2026 by vercel[bot]
Preview – lexical-playground — 9310e788 Deployed Aug 7, 2026 by vercel[bot]
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.

Bug: SKIP_DOM_SELECTION_TAG doesn't work during state initialization

2 participants