Skip to content

Conversation

@fantactuka
Copy link
Collaborator

@fantactuka fantactuka commented Oct 26, 2025

In some cases, the selection is created based on the DOM selection ($internalCreateSelection$internalCreateRangeSelection$internalResolveSelectionPoints), and it doesn't match the editor state. This selection isn't marked as dirty (since it's already in sync with the DOM). The issue is that it skips the block cursor update, causing the editor to keep the fake cursor in the wrong position.

You can reproduce this issue in the playground using a collapsible block that contains a YouTube node. After selecting the YouTube node, moving the selection with the down arrow key creates a block cursor initially but fails to reset it back to a regular caret.

Another potential fix location:
When creating the DOM-based selection, we could compare it to the existing one and mark it as dirty if it differs. However, since this happens in $beginUpdate, and with batched updates it might run multiple times per commit, running the comparison during the commit phase might be slightly better.

Test plan

Before

Changed hidden caret-color from transparent to red for a demo purpose (block cursor remains visible, real caret is still red):

CleanShot.2025-10-26.at.11.16.14.mp4

After

Now red caret turns back to black, and block cursor disappears:

CleanShot.2025-10-26.at.11.15.47.mp4

@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 Oct 26, 2025
@vercel
Copy link

vercel bot commented Oct 26, 2025

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 26, 2025 10:16am
lexical-playground Ready Ready Preview Comment Oct 26, 2025 10:16am

Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Nice catch!

@etrepum etrepum added this pull request to the merge queue Oct 26, 2025
Merged via the queue into facebook:main with commit 38d5dbd Oct 26, 2025
43 of 71 checks passed
This was referenced Oct 27, 2025
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.

2 participants