Skip to content

feat: add focus event option for the checklist extension - #8105

Merged
etrepum merged 13 commits into
meta:mainfrom
rayterion:feat/checklist-focus-option
Feb 21, 2026
Merged

etrepum merged 13 commits into
meta:mainfrom
rayterion:feat/checklist-focus-option

Conversation

@rayterion

@rayterion rayterion commented Jan 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds an optional configuration parameter, disableTakeFocusOnClick, to CheckListExtension. This allows users to enable or disable editor focus when clicking on checklist items, as described in the related issue:

The changes are implemented in a way that does not break existing usages of CheckListExtension or the CheckListPlugin React component. The new parameter is optional and defaults to the current behavior.

Note: In the file LexicalCheckListPlugin.js.flow, I added what I believe is the correct change based on patterns observed in similar files. However, I did not deeply verify the purpose of all files in that directory, so this part should be reviewed.

Test plan

I tested the behavior by running pnpm run start and verifying how checklist items behave when clicked, both with and without the disableTakeFocusOnClick option enabled.
Steps:

  1. Open packages/lexical-playground/src/appSettings.ts and set shouldDisableFocusOnClickChecklist to either false or true (default is false)
  2. run pnpm run start
  3. create a checklist in the editor (shortcut Ctrl+Shift+9 on pc).
  4. Verify the focus behavior

I have not yet explicitly tested whether the mobile keyboard correctly dismisses when the option is set to true. However, in theory, this should work as expected, since the keyboard should only appear when the editor receives focus.

Additional Context

I noticed there is an existing open PR with the same goal as this one, but it was not completed by its author. For reference:

@vercel

vercel Bot commented Jan 31, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 18, 2026 9:01pm
lexical-playground Ready Ready Preview, Comment Feb 18, 2026 9:01pm

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 Jan 31, 2026
Comment thread packages/lexical-list/src/checkList.ts Resolved

@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.

It would be good to add some tests for this feature, right now there's nothing that demonstrates that it works

Comment thread packages/lexical-list/src/index.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
Comment thread packages/lexical-list/src/checkList.ts Resolved
@etrepum

etrepum commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

This feature still doesn't have any tests, when you add some I will take another look

@rayterion

Copy link
Copy Markdown
Contributor Author

This feature still doesn't have any tests, when you add some I will take another look

I've added the test file. I took a little longer because i was trying to understand the standards for testing in Lexical, but i think i got it right.

@rayterion
rayterion requested a review from etrepum February 6, 2026 03:35
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 6, 2026

@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.

In this case since we're dealing with focus, etc. and you're using mocks to change the environment's behavior it seems like a better approach would be to write an e2e test for this feature that uses a real browser. Mocking here makes it seem like maybe the tests aren't really doing anything meaningful.

@etrepum
etrepum added this pull request to the merge queue Feb 21, 2026
Merged via the queue into meta:main with commit 2f1189d Feb 21, 2026
37 checks passed
@etrepum etrepum mentioned this pull request Feb 25, 2026
ewsbr added a commit to ewsbr/lexical that referenced this pull request Oct 16, 2026
…t, and swipes from it scroll

## Description

On a phone, a check list's checkbox was hard to tap and impossible to scroll
from:

- A tap toggles on the touch `pointerup`. A finger that moves a few pixels
  during the tap starts a scroll, and the pointer then ends in `pointercancel`,
  so the tap does nothing and the page shifts. Chrome scrolls once the finger
  passes about 8 CSS px; Firefox sends `pointercancel` for any movement at all.
  A checkbox often took two or three taps.
- The `touchstart` on the check mark is canceled (meta#8105) to keep the caret and
  the on-screen keyboard away, which also keeps the touch from scrolling: a
  swipe that starts on a checkbox leaves the page where it is, and its
  `pointerup` then toggles the item (meta#8390).
- The 32px touch padding of the hit area was only ever tested on the `<li>`
  itself, so a touch just left of the checkbox, which lands on the list or
  whatever lies beside it, toggled nothing.

A tap is now taken from touch events, which end in `touchend` either way. The
finger may travel 16px; whatever the drift scrolled is put back and held there
while a fling it started runs out, and the `touchend` is canceled, so the
browser neither places the caret nor sends a click. Moving further is a swipe,
which scrolls and toggles nothing. The `touchstart` is no longer canceled.
Canceling the touchmoves of a tap instead would also keep it from scrolling in
Chrome, but Firefox then holds the whole touch, swipes included.

A touch that lands beside an item is matched to the item within the padding to
either side, and counts only on the marker's side, so a touch on the item's
text still places the caret. The touch listeners are on the document, since
such a touch can land outside the root element.

The touch `pointerup` toggle goes, and with it the window that kept the click
following it from toggling the item again: the canceled `touchend` suppresses
that click.

## Test plan

### Before

Chromium and Firefox on Android 15 (emulator, Gboard), a 30-item check list:

- A tap that drifts 11 CSS px (`input swipe`, 120ms) ends in `pointercancel`,
  toggles nothing, and scrolls the page; at 9px it toggles about half the time.
- A vertical swipe starting on a checkbox does not scroll (scrollTop 15 → 15)
  and checks the item.
- A tap 11px left of the checkbox toggles nothing.

### After

Same devices:

- Taps drifting up to 15px toggle the item once, and the page stays where it
  was (scrollTop change 0, from 2–14px in Chromium without the hold).
- Swipes of 60–700px starting on a checkbox scroll and toggle nothing.
- A tap up to 30px left of the checkbox toggles it; a tap on the item's text
  places the caret and opens the keyboard.
- With the keyboard open, taps toggle the item and the keyboard stays open.

`pnpm vitest --project unit --no-watch packages/lexical-list`:

```text
 Test Files  16 passed (16)
      Tests  152 passed (152)
```

`tsc`, `tsc-test`, ESLint, and Prettier pass. iOS Safari was not exercised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ewsbr added a commit to ewsbr/lexical that referenced this pull request Oct 21, 2026
…t, and swipes from it scroll

## Description

On a phone, a check list's checkbox was hard to tap and impossible to scroll
from:

- A tap toggles on the touch `pointerup`. A finger that moves a few pixels
  during the tap starts a scroll, and the pointer then ends in `pointercancel`,
  so the tap does nothing and the page shifts. Chrome scrolls once the finger
  passes about 8 CSS px; Firefox sends `pointercancel` for any movement at all.
  A checkbox often took two or three taps.
- The `touchstart` on the check mark is canceled (meta#8105) to keep the caret and
  the on-screen keyboard away, which also keeps the touch from scrolling: a
  swipe that starts on a checkbox leaves the page where it is, and its
  `pointerup` then toggles the item (meta#8390).

A tap is now taken from touch events, which end in `touchend` either way. The
finger may travel 16px; whatever the drift scrolled is put back and held there
while a fling it started runs out, and the `touchend` is canceled, so the
browser neither places the caret nor sends a click. Moving further is a swipe,
which scrolls and toggles nothing. The `touchstart` is no longer canceled.
Canceling the touchmoves of a tap instead would also keep it from scrolling in
Chrome, but Firefox then holds the whole touch, swipes included.

The touch `pointerup` toggle goes, and with it the per-item dedup window that
kept the click following it from toggling the item again: the canceled
`touchend` suppresses that click. Mouse clicks are unchanged, and tests that
desktop clicks toggle every time and that taps on two items toggle both are
kept.

## Test plan

### Before

`pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/checkList.test.tsx`:

```text
× a tap on the marker toggles the item once, canceling the pointerdown and touchend but not the touchstart
     × a tap whose finger drifts within the slop still toggles
     × taps on two different items toggle both
AssertionError: expected true to be false // Object.is equality
AssertionError: expected false to be true // Object.is equality
      Tests  3 failed | 2 passed (5)
```

Chromium and Firefox on Android 15 (emulator, Gboard), a 30-item check list:

- A tap that drifts 11 CSS px (`input swipe`, 120ms) ends in `pointercancel`,
  toggles nothing, and scrolls the page; at 9px it toggles about half the time.
- A vertical swipe starting on a checkbox does not scroll (scrollTop 15 → 15)
  and checks the item.

### After

```text
Tests  5 passed (5)
```

`pnpm exec vitest run --project unit packages/lexical-list`:

```text
Test Files  16 passed (16)
      Tests  152 passed (152)
```

Same devices:

- Taps drifting up to 15px toggle the item once, and the page stays where it
  was (scrollTop change 0, from 2–14px in Chromium without the hold).
- Swipes of 60–700px starting on a checkbox scroll and toggle nothing.
- With the keyboard open, taps toggle the item and the keyboard stays open.

`tsc`, ESLint and Prettier pass. iOS Safari was not exercised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ewsbr added a commit to ewsbr/lexical that referenced this pull request Oct 22, 2026
…t, and swipes from it scroll

## Description

On a phone, a check list's checkbox was hard to tap and impossible to scroll
from:

- A tap toggles on the touch `pointerup`. A finger that moves a few pixels
  during the tap starts a scroll, and the pointer then ends in `pointercancel`,
  so the tap does nothing and the page shifts. Chrome scrolls once the finger
  passes about 8 CSS px; Firefox sends `pointercancel` for any movement at all.
  A checkbox often took two or three taps.
- The `touchstart` on the check mark is canceled (meta#8105) to keep the caret and
  the on-screen keyboard away, which also keeps the touch from scrolling: a
  swipe that starts on a checkbox leaves the page where it is, and its
  `pointerup` then toggles the item (meta#8390).

A tap is now taken from touch events, which end in `touchend` either way. The
finger may travel 16px; whatever the drift scrolled is put back and held there
while a fling it started runs out, and the `touchend` is canceled, so the
browser neither places the caret nor sends a click. Moving further is a swipe,
which scrolls and toggles nothing. The `touchstart` is no longer canceled.
Canceling the touchmoves of a tap instead would also keep it from scrolling in
Chrome, but Firefox then holds the whole touch, swipes included.

The touch `pointerup` toggle goes, and with it the per-item dedup window that
kept the click following it from toggling the item again: the canceled
`touchend` suppresses that click. Mouse clicks are unchanged, and tests that
desktop clicks toggle every time and that taps on two items toggle both are
kept.

## Test plan

### Before

`pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/checkList.test.tsx`:

```text
× a tap on the marker toggles the item once, canceling the pointerdown and touchend but not the touchstart
     × a tap whose finger drifts within the slop still toggles
     × taps on two different items toggle both
AssertionError: expected true to be false // Object.is equality
AssertionError: expected false to be true // Object.is equality
      Tests  3 failed | 2 passed (5)
```

Chromium and Firefox on Android 15 (emulator, Gboard), a 30-item check list:

- A tap that drifts 11 CSS px (`input swipe`, 120ms) ends in `pointercancel`,
  toggles nothing, and scrolls the page; at 9px it toggles about half the time.
- A vertical swipe starting on a checkbox does not scroll (scrollTop 15 → 15)
  and checks the item.

### After

```text
Tests  5 passed (5)
```

`pnpm exec vitest run --project unit packages/lexical-list`:

```text
Test Files  16 passed (16)
      Tests  152 passed (152)
```

Same devices:

- Taps drifting up to 15px toggle the item once, and the page stays where it
  was (scrollTop change 0, from 2–14px in Chromium without the hold).
- Swipes of 60–700px starting on a checkbox scroll and toggle nothing.
- With the keyboard open, taps toggle the item and the keyboard stays open.

`tsc`, ESLint and Prettier pass. iOS Safari was not exercised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 78c0c8cd Deployed Feb 18, 2026 by vercel[bot]
Preview – lexical — 78c0c8cd Deployed Feb 18, 2026 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.

Feature: Add an option to disable focus on click in CheckListPlugin

3 participants