Skip to content

[lexical-list] Bug Fix: Dragging a selection onto a check box no longer checks the item - #9

Closed
Vedthakar wants to merge 1 commit into
mainfrom
fix/4861-checklist-drag-release
Closed

Vedthakar wants to merge 1 commit into
mainfrom
fix/4861-checklist-drag-release

Conversation

@Vedthakar

Copy link
Copy Markdown
Owner

Description

This solves issue meta#4861: a check list item gets checked when you select its text by dragging and release the mouse over its check box.

Current behavior. A drag that starts in the item's text and ends over the check mark still produces a click on the <li>, the nearest common ancestor of the press and the release. handleCheckItemEvent decides from that click's coordinates only, which are the release point, so the item toggles.

The plugin already records what each press landed on (lastPress: 'checkMark', 'content' or 'none') for its focus handling, but it can't be used as it stands. The pointerup handler runs before the click and resets lastPress to 'none'. By the time the click arrives, every real mouse gesture looks like a press-less click.

What this changes.

  • The pointerup handler keeps the press of the gesture it ended (releasedPress) for the click that follows. It only does this for the primary button, since a right click has no click after it.
  • click and the touch pointerup path toggle only when that press wasn't on the item's content:
    • a press on the check mark still toggles;
    • 'none' (a click with no press behind it, such as one a screen reader synthesizes) still toggles;
    • a press on the content released over the check mark no longer toggles.
  • releasedPress is cleared by the click and by the next press, so it never carries over to a later gesture.
  • The focus handling and the touch dedup window are unchanged.

This doesn't overlap with open PR meta#9106, which edits a different part of checkList.ts (the Space handler).

Closes meta#4861

Test plan

New tests in packages/lexical-list/src/__tests__/unit/checkList.test.tsx, which already stubs the ::before width for jsdom. They dispatch full gestures: pointerdown/mousedown, pointerup/mouseup, click.

  • "does not toggle the item (a text selection dragged onto it)": a mouse press on the content, released over the check mark.
  • "does not toggle the item on touch either": the same with touch pointer events.
  • "does not carry over to a later check mark press": a drag like the one above, then a normal check mark click, toggles exactly once.
  • Controls:
    • a press and release on the check mark still toggles;
    • a click with no press (screen reader) still toggles;
    • after a right click on the content, the next click on the check mark still toggles.

The existing mobile tap and dedup tests in the file pass unchanged.

Before

On main with the tests applied and the source change reverted:

$ pnpm exec vitest run packages/lexical-list/src/__tests__/unit/checkList.test.tsx
  × does not toggle the item (a text selection dragged onto it)
  × does not toggle the item on touch either
  × does not carry over to a later check mark press
  Tests  3 failed | 9 passed (12)

After

  checkList.test.tsx: 12 passed
  test-unit: 388 files, 9409 passed | 1 skipped
  tsc, flow, eslint, prettier: clean
  e2e List: chromium 42 passed; firefox (check list tests) 14 passed

Author: Ved Thakar (@Vedthakar)

…er checks the item

The click and pointerup handlers decided on the release position only, and
the pointerup consumed the recorded press before the click ran. A text
selection started in the item and released over the check mark therefore
toggled it. Keep the press of the gesture for its click and toggle only
when it wasn't on the item's content.

Signed-off-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com>
Co-authored-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Vedthakar
Vedthakar force-pushed the fix/4861-checklist-drag-release branch from 012da9f to fda47c9 Compare October 21, 2026 21:37
@Vedthakar

Copy link
Copy Markdown
Owner Author

Superseded by meta#9429.

@Vedthakar Vedthakar closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Checklist item becomes completed when releasing the selection within the checklist item box

1 participant