Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
… toggles the item ## Description On a touch screen, a finger that lands on a check list item's check mark and moves, for example to scroll through the list, toggles the item when it lifts. Only a tap should. Touch pointers are captured by the element they went down on, so the `pointerup` of that swipe still reaches the item, and the touch `pointerup` path decides from the release point's x coordinate alone, which a vertical swipe keeps inside the check mark's hit area. That path now remembers where each touch went down and ignores a release more than 10px from it along either axis, the same test as core's tap detection; `pointercancel` forgets the touch. A tap, a few pixels of jitter included, toggles as before, and a release with no recorded press is still treated as a tap. The `touchstart` handling is unchanged, so a swipe that starts on a check mark still doesn't scroll the page; this change only stops the toggle. It is separate from meta#9429, which stops a press on the item's text that is released over the check mark from toggling it. ## Test plan ### Before The new tests on `main`: ``` $ pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/checkList.test.tsx × a touch that moves before lifting does not toggle the item ✓ a tap that moves a few pixels still toggles the item AssertionError: expected true to be false // Object.is equality Tests 1 failed | 7 passed (8) ``` ### After ``` $ pnpm exec vitest run --project unit packages/lexical-list Tests 170 passed (170) $ pnpm exec vitest run --project unit Test Files 679 passed | 4 skipped (683) Tests 29169 passed | 373 expected fail | 136 skipped (29678) ``` `pnpm run tsc`, `pnpm run tsc-test`, `pnpm run flow`, `pnpm run check-changesets`, and ESLint and Prettier on the changed files pass. The tests dispatch the pointer events in jsdom; not run on a touch device or simulator.
There was a problem hiding this comment.
Thanks for the fix — this looks good. The drag-from-label case is handled with a small, contained change, and the new tests fail on main and pass here. A few optional, non-blocking suggestions:
-
A press that never finishes inside the editor can veto a later press-less click (
packages/lexical-list/src/checkList.ts, lines 156-163 and 292-306).lastPressis only consumed by the root'spointerup/clicklisteners, so after apointercancel(a touch scroll, or a native drag starting) or a selection dragged out of the editor and released outside it,lastPressstays'content';releasedPresslikewise lingers after a primary release that noclickfollows. The next click with no press behind it — the case the description says should still toggle — is then skipped until the user presses somewhere in the editor again. Resetting both onpointercancel, and applying the content veto only to the click that directly follows the root's ownpointerup, would close this. Each case is a short unit test next to the new ones, e.g. a touchpointerdownon the label, thenpointercancel, then aclickon the check mark should still toggle. -
Consider a real-browser test as well. The new tests run in jsdom with hand-built event sequences, so they cannot show that a browser actually delivers the
clickto the<li>at the release point. AGENTS.md (Testing Strategy) puts behaviour that depends on a real layout or selection engine in browser or e2e tests, andpackages/lexical-playground/__tests__/e2e/List.spec.mjsalready drives check lists withpage.mouse:mouse.down()in the label,mouse.move()onto the box,mouse.up(), then assertaria-checkedis stillfalse. -
Nit: AGENTS.md (Commits and Pull Requests) asks the Test plan's
### Aftersection to paste the actual command output rather than a summary of it.
| : 'content'; | ||
| }; | ||
| const returnFocusAfterPress = () => { | ||
| const press = lastPress === 'none' ? releasedPress : lastPress; |
There was a problem hiding this comment.
Optional: lastPress is only consumed here and by the root's pointerup/click listeners, so a press whose gesture ends with pointercancel (touch scroll, native drag) or outside the editor root stays 'content', and this now hands it to the next click — a click with no press behind it on the check mark is then ignored until the next press in the editor. Resetting lastPress and releasedPress on pointercancel, and honouring the content veto only for the click that directly follows the root's own pointerup, would avoid that.
…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>
A press that ends in pointercancel (eg. a touch that becomes a scroll) is followed by no release or click, so it stayed recorded and made the next click with no press of its own skip the toggle. Co-authored-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
fda47c9 to
0341ba9
Compare
|
Thanks for the review. Taken in the latest push: a press that ends in — Ved Thakar |
There was a problem hiding this comment.
Thanks for the update — this looks good. Dragging a selection from a check list item's text onto its check box no longer checks the item, the new tests fail on main and pass here, and forgetting the press on pointercancel fixes the cancelled-touch case from the earlier round. A few optional, non-blocking suggestions:
-
A press that ends outside the editor still vetoes the next press-less click (
packages/lexical-list/src/checkList.ts, lines 313-327).lastPressis only consumed by the root's ownpointerup/clicklisteners, so a selection dragged from an item's label and released outside the editor leaves it at'content', andreleasedPresslingers after a primary release that is followed by noclick(for example a Control-click on macOS that opens the context menu). The next click with no press behind it on the check mark, the case the plugin's own comment and your screen-reader control test describe, is then ignored until the next press in the editor. Consuming the press from a capturepointerupon the root's owner document as well, and clearingreleasedPressoncontextmenu, would close both. Each is a short unit test next to the cancelled-press one: a press on the label,pointerupandclickdispatched on an element outside the root, then a press-lessclickon the check mark should still toggle. -
Changeset: add a
Verify:paragraph (.changeset/checklist-drag-release-no-toggle.md). CONTRIBUTING.md (Changesets) asks a fix that changes editing behaviour to say what to test, so it is listed under "Behavior changes", as the other check list fixes onmaindo. For example:Verify: in a check list, press in an item's text, drag onto its check mark and release; the item keeps its state and the text stays selected. A click on the check mark still toggles it. -
Consider a real-browser test as well. The new tests run in jsdom with hand-built events, so they cannot show that a browser delivers the
clickto the<li>at the release point. AGENTS.md (Testing Strategy) puts behaviour that depends on real layout in browser or e2e tests, andpackages/lexical-playground/__tests__/e2e/List.spec.mjsalready drives check lists withpage.mouse:mouse.down()in the label,mouse.move()onto the box,mouse.up(), thenaria-checkedstaysfalse. -
Nits: "does not toggle the item on touch either" releases 190px from the press, so on
mainthe swipe check already stops the touchpointerupand only the trailingclickmakes the test fail; and the Test plan's### Beforeoutput shows 12 tests while the file now has 19, with### Aftersummarised rather than pasted, which AGENTS.md (Commits and Pull Requests) asks for.
| configHandleClick(event); | ||
| const press = returnFocusAfterPress(); | ||
| releasedPress = 'none'; | ||
| if (press !== 'content') { |
There was a problem hiding this comment.
Optional: the cancelled-press case is fixed, but lastPress is still consumed only by these root listeners. A selection dragged from the label and released outside the editor delivers its pointerup and click outside the root, so lastPress stays 'content' and this skips the next press-less click on the check mark; releasedPress likewise lingers after a primary release with no click (a macOS Control-click). Consuming the press from a capture pointerup on the root's owner document as well, and clearing releasedPress on contextmenu, would cover both.
| '@lexical/list': patch | ||
| --- | ||
|
|
||
| [fix] A press on a check list item's text that is released over its check mark, such as a text selection dragged onto it, no longer toggles the item |
There was a problem hiding this comment.
Optional: CONTRIBUTING.md (Changesets) asks a fix that changes editing behaviour to add a Verify: paragraph, for example:
Verify: in a check list, press in an item's text, drag onto its check mark and release; the item keeps its state and the text stays selected. A click on the check mark still toggles it.
Description
This solves issue #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
clickon the<li>, the nearest common ancestor of the press and the release.handleCheckItemEventdecides 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. Thepointeruphandler runs before theclickand resetslastPressto'none'. By the time the click arrives, every real mouse gesture looks like a press-less click.What this changes.
pointeruphandler 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.clickand the touchpointeruppath toggle only when that press wasn't on the item's content:'none'(a click with no press behind it, such as one a screen reader synthesizes) still toggles;releasedPressis cleared by the click and by the next press, so it never carries over to a later gesture.This doesn't overlap with open PR #9106, which edits a different part of
checkList.ts(the Space handler).Closes #4861
Test plan
New tests in
packages/lexical-list/src/__tests__/unit/checkList.test.tsx, which already stubs the::beforewidth for jsdom. They dispatch full gestures:pointerdown/mousedown,pointerup/mouseup,click.The existing mobile tap and dedup tests in the file pass unchanged.
Before
On
mainwith the tests applied and the source change reverted:After
On current
main:checkList.test.tsx: 12 passed (the 3 new behaviour tests fail onmain). Chromium e2e:List.spec.mjs, which covers check lists, passes in full.pnpm run test-unit: all 9,580 tests passtsc,pnpm run flow(0 errors), and eslint/prettier on the changed files: cleanAuthor: Ved Thakar (@Vedthakar)
🤖 Generated with Claude Code