Skip to content

[lexical] Bug Fix: Do not apply format and style when moving to different node in composition#8148

Merged
etrepum merged 2 commits intofacebook:mainfrom
kimseongyu:fix-selection-style-inheritance-on-composition
Feb 17, 2026
Merged

[lexical] Bug Fix: Do not apply format and style when moving to different node in composition#8148
etrepum merged 2 commits intofacebook:mainfrom
kimseongyu:fix-selection-style-inheritance-on-composition

Conversation

@kimseongyu
Copy link
Copy Markdown
Contributor

Description

Current Behavior

During IME composition, Lexical's selection protection mechanism attempts to maintain the previous selection to prevent composition breaks. However, when the selection eventually moves to a different node, the RangeSelection inherits the format and style from the lastSelection. This results in the new text having the wrong format and style carried over from the previous node.

Changes in This PR

  • Adjusted the logic to allow selection updates when the composition key and the target node key differ, ensuring the cursor moves correctly.
  • If the selection has moved to a different node, it now initializes the format/style based on the current node's properties instead of blindly inheriting from the previous selection.

Closes #8098

Test plan

Before

before.mov

After

after.mov

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 16, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 17, 2026 0:34am
lexical-playground Ready Ready Preview, Comment Feb 17, 2026 0:34am

Request Review

@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 Feb 16, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 17, 2026
@etrepum etrepum added this pull request to the merge queue Feb 17, 2026
Merged via the queue into facebook:main with commit 42b2e04 Feb 17, 2026
39 checks passed
@kimseongyu kimseongyu deleted the fix-selection-style-inheritance-on-composition branch February 17, 2026 02:08
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 18, 2026
…rent node in composition (facebook#8148)

Co-authored-by: Bob Ippolito <bob@redivi.com>
@etrepum etrepum mentioned this pull request Feb 25, 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.

Bug: IME composition: Format/style inherited from previous selection when clicking another paragraph during composition

2 participants