Skip to content

[lexical] Fix: insert into existing paragraph node if selection is on parent element - #7794

Merged
etrepum merged 1 commit into
meta:mainfrom
james-atticus:root-selection-insert
Sep 2, 2025
Merged

etrepum merged 1 commit into
meta:mainfrom
james-atticus:root-selection-insert

Conversation

@james-atticus

@james-atticus james-atticus commented Sep 2, 2025 •

Copy link
Copy Markdown
Contributor

Description

If the selection is on the root node with an offset that points to a paragraph node, inserting text at the selection creates a new paragraph rather than inserting text into the existing paragraph. Noticed in collab when focusing the editor with the keyboard (i.e. refresh page, click frame outside of editor, tab into the content-editable).

Fixes #7789

Test plan

Before

Focusing editors by keyboard then inserting text results in new paragraphs being added, despite the cursor being positioned at the start of the paragraphs.

Screen.Recording.2025-09-02.at.5.29.12.pm.mov

After

Text is inserted into the existing paragraph.

Screen.Recording.2025-09-02.at.5.31.23.pm.mov

@vercel

vercel Bot commented Sep 2, 2025 •

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Sep 2, 2025 7:42am
lexical-playground Ready Ready Preview Comment Sep 2, 2025 7:42am

@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 Sep 2, 2025
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Sep 2, 2025

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and it fixes an issue that was recently opened so I updated the description accordingly. I suspect that there are some other quirks related to selections that should've been normalized differently.

@etrepum
etrepum added this pull request to the merge queue Sep 2, 2025
Merged via the queue into meta:main with commit 60335bd Sep 2, 2025
@etrepum etrepum mentioned this pull request Sep 5, 2025
polyrainbow added a commit to polyrainbow/neno that referenced this pull request Sep 5, 2025
polyrainbow added a commit to polyrainbow/neno that referenced this pull request Sep 5, 2025

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 3442244c Deployed Sep 2, 2025 by vercel[bot]
Preview – lexical — 3442244c Deployed Sep 2, 2025 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: Unexpected Paragraph after deletion of new lines

3 participants