Repository navigation
[lexical-extension][lexical-playground] Bug Fix: trim triple-click overselection however late the selection change arrives - #9317
Merged
etrepum merged 12 commits intoOct 5, 2026
Conversation
…late the selection change arrives
## Description
`NormalizeTripleClickSelectionExtension` trims the overselection a triple click produces (all of one paragraph plus the start of the next), but only when the `selectionchange` that follows is handled within `thresholdMsec` (100 ms) of the click's mouse events. On a busy machine the selection change arrives later, the trim is skipped, and the focus stays at the start of the next paragraph, so a following block format applies to both paragraphs. This is what makes the e2e test "Selection › Can adjust selection on 3+ clicks" flaky; with the CPU slowed 20x it fails every time, on main as well.
This replaces the wall-clock window with event ordering. A mousedown with `detail > 2` arms the extension, and the next `SELECTION_CHANGE_COMMAND` consumes it and runs `$fixFocusOverselection`. Any other mousedown (a single or double click) or a keydown disarms it. The browser applies the paragraph selection as the default action of that mousedown, so any selection change handled after it reads at least that selection however late it arrives. The mouseup listener is gone, since it could only re-arm after the selection change had already been handled.
`thresholdMsec` and `dateNow` are still accepted in the config and output so existing setups keep type checking, but are marked `@deprecated` and no longer used.
## Test plan
New unit tests in `packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts` cover a late selection change (1 s after the click, with a faked `Date`), a fourth click, only the first change being trimmed, and keydown, single click and double click cancelling it.
The e2e reproduction slows the CPU with `Emulation.setCPUThrottlingRate` (rate 20) through a CDP session right before the `click({clickCount: 4})` in "Can adjust selection on 3+ clicks" (a local edit, not part of this change), on Chromium 141 headless shell.
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× trims the selection change however late it arrives
× a keydown cancels it
× a single or double click cancels it
Tests 3 failed | 4 passed (7)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=3 --retries=0
3 failed
Error: expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Array [
- 0,
+ 1,
0,
0,
]
> 661 | expect(selection.focusPath).toEqual(expected.focusPath);
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 7 passed (7)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (26.3s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs --retries=0
12 skipped
160 passed (3.9m)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 339 passed (339)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…y click or key in the document
## Description
After the previous commit, a triple click armed `NormalizeTripleClickSelectionExtension` until the next selection change, and only a mousedown or keydown inside the editor root disarmed it. A triple click that changed nothing (a one-word paragraph the double click already selected) therefore stayed armed, and a later selection change made by code, such as a toolbar button outside the editor or undo, could have its end trimmed back into the previous block. Any keydown also disarmed it, including a modifier on its own, so on a busy machine pressing Ctrl or Alt to start a shortcut before the queued `selectionchange` was handled cancelled the trim.
The mousedown and keydown listeners now sit on the root's owner document (capture phase). A mousedown arms only when it is a triple or later click inside the editor (checked with `composedPath()` so shadow roots work); any other mousedown or keydown anywhere in the document disarms, except keydowns of modifier keys alone (Alt, AltGraph, CapsLock, Control, Fn, Meta, Shift).
## Test plan
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× a modifier key on its own does not cancel it
× a click or keydown outside the editor cancels it
Tests 2 failed | 8 passed (10)
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 10 passed (10)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 342 passed (342)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (31.8s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs --retries=0
12 skipped
160 passed (3.9m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
October 2, 2026 22:30
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… that come from the browser
## Description
A triple click arms `NormalizeTripleClickSelectionExtension` with no time limit, and a mousedown or non-modifier keydown in the editor's document disarms it. Two gaps remained when a triple click changed nothing and so left it armed. A toolbar that calls `preventDefault()` on `pointerdown` to keep focus suppresses `mousedown`, and a toolbar in a parent frame sends nothing into the editor's document. In both cases, a selection change made by code afterwards (undo, selecting an inserted block, a collab update, a drop) could have its end pulled back into the previous block.
Two changes close this:
- A `pointerdown` anywhere in the document also disarms it. It can't be cancelled and always comes before `mousedown`, which still re-arms on a triple click in the editor.
- The selection change is only trimmed when Lexical's selection matches the one `$createRangeSelectionFromDom` reads from the DOM, so the change came from the browser. A selection set by code is not in the DOM yet when `SELECTION_CHANGE_COMMAND` runs, so it is left alone, and the arm is used up either way.
## Test plan
### Before
The unit tests now put the triple-click selection in the DOM and fire `selectionchange`, the way the browser does, and two cases are new.
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× does not trim a selection change made by code
× a pointerdown cancels it, even without a mousedown
Tests 2 failed | 10 passed (12)
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 12 passed (12)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 344 passed (344)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (34.9s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs --retries=0
12 skipped
160 passed (4.2m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ng-b8gvyp' into claude/triple-click-event-ordering-b8gvyp
## Description
`NormalizeTripleClickSelectionExtension` only trims a selection change that came from the browser, which it checks by comparing Lexical's selection with one rebuilt from the DOM using `selection.is(fromDOM)`. That also compares `format` and `style`. A selection the browser makes over formatted text gets the format and style the selected text shares, but the one rebuilt by `$createRangeSelectionFromDom` always has format 0 and no style. So triple-clicking an all-bold paragraph never matched, the trim was skipped, and a block format applied afterwards changed the next paragraph too.
The check now compares only the anchor and focus points.
## Test plan
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× trims a triple click on formatted text
Tests 1 failed | 12 passed (13)
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 13 passed (13)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 345 passed (345)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (26.9s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs --retries=0
12 skipped
160 passed (3.8m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ion changes made by code
## Description
`NormalizeTripleClickSelectionExtension` used up its arm on the first `SELECTION_CHANGE_COMMAND` after a triple click, even when it skipped the trim because that selection was set by code rather than read from the DOM. Core dispatches this command for any update that changes the selection. So on a busy machine, a collab edit or a deferred `$setSelection` landing before the browser's late `selectionchange` used up the arm, and the triple click's own overselection was never trimmed.
The arm is now used up only by a selection change that matches the DOM selection, which is the one it trims. A change made by code leaves it armed; it is still disarmed by the next pointerdown, mousedown or non-modifier keydown, as before.
## Test plan
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× still trims the triple click after a selection change made by code
Tests 1 failed | 13 passed (14)
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 14 passed (14)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 346 passed (346)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (31.7s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs --retries=0
12 skipped
160 passed (3.8m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t guard in e2e helpers
## Description
On Chrome for macOS, Lexical ignores an `insertText` that arrives after a handled Backspace or select all and before a zero-delay timer clears the guard, because the OS can use it to accept a pending text replacement. A real keystroke always arrives after that timer. Text that Playwright types with `Input.insertText` has no key event, which includes an emoji or any character with no key on the US layout. On a busy runner, input is handled ahead of timers, so that text can arrive first and be dropped. That is how "MaxLength › can restrict emojis on boundaries" failed on every attempt on macOS Chromium: `clearEditor` ended with a handled Backspace, the first 👨 of the typed 👨💻 sequence was swallowed, and the result was `💻👨💻👨💻👨💻👨💻👨💻👨` instead of six whole emoji.
A new `waitForTimerTick(page)` helper waits for one zero-delay timer in the page. Timers with the same delay run in order, so once it resolves the guard has been cleared. `selectAll`, `pressBackspace` and `clearEditor` now call it before returning.
## Test plan
A probe spec (not committed) fakes `navigator.platform` as `MacIntel`, types `ab`, then sends Backspace and `Input.insertText('X')` concurrently, expecting `aX`.
### Before
```
$ playwright test --project=chromium ZZProbe.spec.mjs --repeat-each=5 --retries=0
- <span data-lexical-text="true">aX</span>
+ <span data-lexical-text="true">a</span>
5 failed
```
### After
The same probe with `waitForTimerTick(page)` between the Backspace and the `insertText`:
```
$ WAIT=1 playwright test --project=chromium ZZProbe.spec.mjs --repeat-each=5 --retries=0
5 passed (12.2s)
$ playwright test --project=chromium MaxLength.spec.mjs Selection.spec.mjs TextFormatting.spec.mjs History.spec.mjs --retries=0
11 skipped
83 passed (2.2m)
```
Only Linux Chromium with a faked macOS platform was run; real macOS, Firefox and WebKit were not.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…it reaches the DOM
## Description
`NormalizeTripleClickSelectionExtension` trims the first selection change after a triple click whose anchor and focus match the DOM selection, treating that as proof the browser made it. A selection set by code also reaches the DOM after reconciliation, and Lexical can report that as a selection change, which then matched and was trimmed. For example, a third-click handler that cancels the mousedown and selects from paragraph 1 to the start of paragraph 2 kept its range at first, then had the focus pulled back to the end of paragraph 1 when the DOM update was reported.
The extension now keeps the arming mousedown and drops the arm without trimming in two more cases:
- the mousedown was cancelled with `preventDefault()`, so the browser made no selection;
- after the mouseup, when the browser has applied its selection, the DOM no longer holds the selection it had at the mouseup, because code replaced it.
A selection change reported before the mouseup is trimmed as before, as is a native selection reported late after the mouseup.
## Test plan
Two new unit tests reproduce the finding (a cancelled third-click mousedown with a selection set by code, and a selection set by code after the mouseup, each followed by the DOM's `selectionchange`), and a third checks that a native selection reported after the mouseup is still trimmed. The unit helper's mousedown is now cancelable, like a real one.
A browser probe (not committed) adds a third-click mousedown handler to the playground that calls `preventDefault()` and selects from paragraph 1 to the start of paragraph 2, then triple-clicks paragraph 1.
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× does not trim a selection set by code once it reaches the DOM
× does not trim a selection set by code after the mouseup
Tests 2 failed | 15 passed (17)
$ playwright test --project=chromium ZZProbe.spec.mjs --repeat-each=3 --retries=0
(3 of 3 fail: the focus is trimmed back to paragraph 1, focusPath [0, 0, 0])
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 17 passed (17)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 349 passed (349)
$ playwright test --project=chromium ZZProbe.spec.mjs --repeat-each=3 --retries=0
3 passed (7.1s)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (26.3s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs MaxLength.spec.mjs --retries=0
12 skipped
165 passed (4.2m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ng-b8gvyp' into claude/triple-click-event-ordering-b8gvyp
…ion set by code reaches the DOM
## Description
`NormalizeTripleClickSelectionExtension` decided whether a selection change after a triple click came from the browser by matching the DOM selection, plus a snapshot of the DOM selection taken at the mouseup. Before the mouseup there was no snapshot, so a selection set by code while the button was still held (for example after a fourth click on an already-selected paragraph, which changes nothing natively) was written to the DOM, its `selectionchange` matched, and it was trimmed: the focus moved from the start of the next paragraph back to the end of the first.
The extension now notices the write itself. When a selection change that doesn't match the DOM (so it was set by code) is reported, it records the DOM selection; after that update commits, if the DOM selection has changed, the browser's selection has been replaced and the arm is dropped without a trim. A write made while the mousedown is still being dispatched is ignored, since its default action then replaces it with the browser's selection, and a selection set by code that is not written to the DOM leaves the browser's selection, and the arm, in place. This replaces the mouseup snapshot. A cancelled mousedown still drops the arm.
## Test plan
A new unit test sets a selection by code after a fourth-click mousedown with no mouseup, then reports the DOM's `selectionchange`. The existing "still trims the triple click after a selection change made by code" test now models the case the arm is kept for: the browser's selection is in the DOM and code changes Lexical's selection without writing it to the DOM (`SKIP_DOM_SELECTION_TAG`) before the late `selectionchange`.
The browser check is the review's spec (not committed): type `Paragraph 1` and `Word`, click the last paragraph `clickCount - 1` times, hold the next mousedown, select from paragraph 1 to the start of paragraph 2 by code, wait 200 ms, and expect the focus to stay at `Word`, offset 0, for 3, 4 and 5 clicks.
### Before
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
× does not trim a selection set by code while the button is held
Tests 1 failed | 17 passed (18)
$ playwright test --project=chromium ZZHeld.spec.mjs --retries=0
✓ review held mouse programmatic DOM echo 3
✘ review held mouse programmatic DOM echo 4
✘ review held mouse programmatic DOM echo 5
2 failed
1 passed
```
### After
```
$ vitest run --project unit packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.ts
Tests 18 passed (18)
$ vitest run --project unit packages/lexical-extension packages/lexical-rich-text packages/lexical-plain-text
Test Files 33 passed (33)
Tests 350 passed (350)
$ playwright test --project=chromium ZZHeld.spec.mjs --repeat-each=3 --retries=0
9 passed (22.6s)
$ THROTTLE=20 playwright test --project=chromium Selection.spec.mjs -g "3\+ clicks" --repeat-each=5 --retries=0
5 passed (41.6s)
$ playwright test --project=chromium Selection.spec.mjs TextFormatting.spec.mjs BlockWithAlignableContents.spec.mjs Tables.spec.mjs MaxLength.spec.mjs --retries=0
12 skipped
165 passed (5.3m)
```
Firefox and WebKit were not run (only Chromium is available here).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
potatowagon
approved these changes
Oct 5, 2026
zurfyx
added a commit
that referenced
this pull request
Oct 15, 2026
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -7 3:### Breaking changes 28:### Features 36:### Fixes 98:### Performance 102:### Other 106:### Contributors 110:### All changes $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
zurfyx
added a commit
that referenced
this pull request
Oct 15, 2026
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). Four fixes change observable output or behavior, so their changesets have a `Verify:` paragraph and are listed under Behavior changes: #9303 (new tabs get no `window.opener`), #9272 (imported code content is normalized), #9261 (`$patchStyleText` styles the selection it is given), #9319 (editor keys and namespaces are a counter without a DOM). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -8 3:### Breaking changes 28:### Behavior changes 54:### Features 62:### Fixes 108:### Performance 112:### Other 116:### Contributors 120:### All changes $ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md ### Behavior changes - **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303)) This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged. Verify: pages opened from editor links that relied on `window.opener`. $ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])] $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
zurfyx
added a commit
that referenced
this pull request
Oct 15, 2026
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). Four fixes change observable output or behavior, so their changesets have a `Verify:` paragraph and are listed under Behavior changes: #9303 (new tabs get no `window.opener`), #9272 (imported code content is normalized), #9261 (`$patchStyleText` styles the selection it is given), #9319 (editor keys and namespaces are a counter without a DOM). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -8 3:### Breaking changes 28:### Behavior changes 54:### Features 62:### Fixes 108:### Performance 112:### Other 116:### Contributors 120:### All changes $ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md ### Behavior changes - **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303)) This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged. Verify: pages opened from editor links that relied on `window.opener`. $ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])] $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NormalizeTripleClickSelectionExtensiontrims the overselection a triple click produces (all of one paragraph plus the start of the next), but only when theselectionchangethat follows is handled withinthresholdMsec(100 ms) of the click's mouse events. On a busy machine the selection change arrives later, the trim is skipped, and the focus stays at the start of the next paragraph, so a following block format applies to both paragraphs. This is what makes the e2e test "Selection › Can adjust selection on 3+ clicks" flaky; with the CPU slowed 20x it fails every time.This replaces the wall-clock window with event ordering. A mousedown inside the editor with
detail > 2arms the extension, and the next selection change that came from the browser consumes it and runs$fixFocusOverselection. The browser applies the paragraph selection as the default action of that mousedown, so any selection change handled after it reads at least that selection however late it arrives.Since the arm no longer expires, these guards keep it from trimming the wrong selection change, such as after a triple click that changed nothing (a one-word paragraph the double click already selected):
composedPath()decides whether a click is inside the editor, so shadow roots work.pointerdowncovers toolbars that callpreventDefault()on it to keep focus, which suppressesmousedown. A modifier key pressed on its own (Alt, AltGraph, CapsLock, Control, Fn, Meta, Shift) doesn't disarm it, so starting a shortcut before a lateselectionchangeis handled keeps the trim.$createRangeSelectionFromDomreads from the DOM. A selection set by code (undo, selecting an inserted block, a collab update, a toolbar in a parent frame) is not in the DOM yet whenSELECTION_CHANGE_COMMANDruns, so it is left alone and the extension stays armed for the browser's own selection change. Format and style are not compared, since a browser selection over formatted text takes on that text's format while the one rebuilt from the DOM has none.preventDefault()(the browser made no selection), and, after the mouseup, when the DOM no longer holds the selection it had at the mouseup (code replaced the browser's selection). For example, a third-click handler that cancels the mousedown and selects its own range keeps that range.The mouseup listener now only records the DOM selection; it no longer re-arms.
thresholdMsecanddateNoware still accepted in the config and output so existing setups keep type checking, but are marked@deprecatedand no longer used.This also hardens the e2e helpers against a macOS Chrome race that failed "MaxLength › can restrict emojis on boundaries" on every attempt in CI. On Chrome for macOS, Lexical ignores an
insertTextthat arrives after a handled Backspace or select all and before a zero-delay timer clears the guard, because the OS can use it to accept a pending text replacement. Text Playwright types withInput.insertText(such as an emoji) has no key event and, on a busy runner, can arrive before that timer, so the first 👨 afterclearEditorwas dropped. A newwaitForTimerTick(page)helper waits for one zero-delay timer in the page, andselectAll,pressBackspaceandclearEditorcall it before returning.Test plan
New unit tests in
packages/lexical-extension/src/__tests__/unit/NormalizeTripleClickSelection.test.tsput the triple-click selection in the DOM and fireselectionchange, the way the browser does. They cover:Date), formatted and styled text, a fourth click, and a native selection reported after the mouseup;The e2e reproduction slows the CPU with
Emulation.setCPUThrottlingRate(rate 20) through a CDP session right before theclick({clickCount: 4})in "Can adjust selection on 3+ clicks" (a local edit, not part of this change), on Chromium 141 headless shell. The MaxLength race was reproduced with a probe spec (not committed) that fakesnavigator.platformasMacInteland sends Backspace andInput.insertText('X')concurrently after typingab.Before
After
Only Linux Chromium was run (with a faked macOS platform for the MaxLength race); real macOS, Firefox and WebKit were not.