Skip to content

[lexical-playground] Bug Fix: avoid node selection on CardNode drag release - #9135

Merged
etrepum merged 2 commits into
facebook:mainfrom
kavyansh18:fix/host-chrome-selection-mouse-release
Sep 8, 2026
Merged

etrepum merged 2 commits into
facebook:mainfrom
kavyansh18:fix/host-chrome-selection-mouse-release

Conversation

@kavyansh18

Copy link
Copy Markdown
Contributor

Description

When selecting text inside an editable slot of a CardNode, releasing the mouse over the node's chrome area could incorrectly trigger a NodeSelection for the entire card.

This happened because registerHostChromeSelection handled the mousedown and subsequent CLICK_COMMAND independently. It checked only the target of the click, so a click synthesized after dragging from a slot to the card chrome could be interpreted as an intentional click on the host node.

This PR fixes the issue by tracking the host node on which the mousedown started and only promoting that node to a NodeSelection when the subsequent click corresponds to the same host.

Changes

  • Track the host NodeKey when a mousedown occurs on host chrome.
  • Require the click target to resolve to the same host node before creating a NodeSelection.
  • Clear the tracked key after each click and when the editor root changes to prevent stale interaction state.
  • Preserve the existing behavior for intentional clicks directly on host chrome.
  • Add a regression test covering text-selection drag release over CardNode chrome.

Closes #9115

Test plan

Before

The new regression test was run against the unpatched implementation.

The test failed as expected because releasing over the card chrome incorrectly promoted the card to a NodeSelection:

FAIL ... CardNode.test.ts
AssertionError: expected true to be false

Tests 1 failed | 16 passed (17)

This reproduces the behavior described in #9115.

After

After applying the fix:

  • CardNode regression test: 17/17 passed
  • PullQuoteNode tests: 10/10 passed
  • lexical-playground unit test suite: 357/357 passed
  • TypeScript: passed
  • Flow: passed
  • ESLint: passed with 0 errors/warnings
  • Prettier: passed
  • git diff --check: passed

The regression test also verifies that an intentional mousedown + click on the host chrome still correctly creates a NodeSelection.

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 8, 2026 6:22pm UTC
lexical-playground Ready Ready Preview Sep 8, 2026 6:22pm UTC

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 Sep 8, 2026
@kavyansh18

Copy link
Copy Markdown
Contributor Author

hey @etrepum can you please review the PR

Comment thread packages/lexical-playground/src/nodes/hostChromeSelection.ts Outdated
Use:

Use the latest editor state when resolving the chrome target to match the DOM state at event time.

Co-authored-by: Bob Ippolito <bob@redivi.com>
@kavyansh18

Copy link
Copy Markdown
Contributor Author

Thanks for the review @etrepum . Applied the suggested change to use the latest editor state.

@kavyansh18
kavyansh18 requested a review from etrepum September 8, 2026 18:24
@etrepum etrepum changed the title fix(playground): avoid node selection on drag release [lexical-playground] Bug Fix: avoid node selection on drag release Sep 8, 2026
@etrepum etrepum changed the title [lexical-playground] Bug Fix: avoid node selection on drag release [lexical-playground] Bug Fix: avoid node selection on CardNode drag release Sep 8, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Sep 8, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 8, 2026
Merged via the queue into facebook:main with commit ab09c2a Sep 8, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 17, 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: Releasing the mouse over the chrome target area triggers node selection

2 participants