Repository navigation
[lexical-table] Bug Fix: keep iOS empty-cell double taps inside the cell - #9267
Merged
Merged
Conversation
## Description On iOS, double-tapping an empty table cell can create a native selection reaching into surrounding content without dispatching a second pointer event. Table selection normalization expands that range, so typing or pressing Backspace deletes the table and surrounding text. Remember the tapped cell through pointerup and restore the previous caret when a native range escapes a cell composed of empty blocks, including multiple empty paragraphs. Clear that state on another pointer action, drag, cancellation, keyboard input, or blur. Preserve programmatic selections, existing ranges, and selections from cells containing text. Add 30 browser regression tests that replay the reported DOM selection through the document selectionchange handler. Cover both selection directions, multiple empty paragraphs, synthesized double-click events, cell DOM endpoints, subsequent typing and Backspace, and controls for intentional selection and gesture cleanup. The controls include text elsewhere in the same cell, programmatic cross-cell ranges, and keyboard events whose propagation is stopped at the root. Closes meta#9266 ## Test plan ### Before The original browser regression suite on main, before this fix: `VITEST_BROWSER=webkit node_modules/.bin/vitest run --project browser packages/lexical-table/src/__tests__/browser/EmptyCellTouchSelection.test.ts` ```text AssertionError: expected to have a length of 4 but got +0 Test Files 1 failed (1) Tests 7 failed | 12 passed (19) ``` The expanded suite with the previous PR implementation applied to current main (30772fe), before allowing multiple empty blocks, using the same command: ```text Test Files 1 failed (1) Tests 6 failed | 24 passed (30) ``` These six failures cover both selection directions from the first or last empty paragraph and insertion/Backspace after the escaped range. ### After `VITEST_BROWSER=webkit node_modules/.bin/vitest run --project browser packages/lexical-table/src/__tests__/browser` ```text Test Files 5 passed (5) Tests 48 passed (48) ``` This includes all 30 new browser regression tests. They are picked up by the existing Chromium browser CI job and extended macOS WebKit job. `node_modules/.bin/vitest run --project unit packages/lexical-table/src/__tests__/unit` ```text Test Files 20 passed (20) Tests 209 passed (209) ``` `node_modules/.bin/tsc --noEmit -p tsconfig.test.json` and ESLint on the three changed files exit 0 with no diagnostics. Prettier reports: ```text Checking formatting... All matched files use Prettier code style! ``` WebKit ran locally on Linux with its dependencies loaded from a workspace directory. Chromium could not be run locally because its browser download returned an invalid archive. Physical iOS testing was not available: the browser tests replay the reported DOM selection and events rather than UIKit gesture recognition, and do not verify the one-frame selection flash.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
September 29, 2026 04:27
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
September 29, 2026 04:27
zurfyx
approved these changes
Sep 30, 2026
This was referenced Oct 12, 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) ```
SujinKim1127
added a commit
to SujinKim1127/lexical
that referenced
this pull request
Oct 23, 2026
…double tap cannot select past it ## Description On iOS, double tapping an empty table cell makes WebKit select back to the nearest preceding word, which lies outside the table. meta#9267 restores the caret after `selectionchange`, but iOS paints the native highlight before the page is notified, so the preceding content still flashes on every double tap (meta#9347). The second tap dispatches no cancelable event, and page CSS does not affect the highlight. As suggested in review, this replaces the per-cell editing host from the previous commit with a much smaller change and reverts its other parts (the cell wrapper, the empty-cell Backspace guard, and the window blur / touch marker changes); `LexicalTableSelectionHelpers` is back to `main`. - Empty cell overlay (`LexicalTableIOSEmptyCellOverlay`): after a short, still touch tap in an empty cell, that cell is covered for 500ms by an unmanaged `contenteditable="false"` overlay. A second tap in that window lands on the overlay instead of editable text, so iOS does not start a word selection, and the overlay places the caret in the cell. Outside the window nothing covers the cell, so long press and long press drag keep working. Drags, long presses, and touches iOS takes over (`pointercancel`) never add it. The overlay goes away when the window ends, another cell is tapped, or the cell gets content, and the cell's inline `position` is restored with it. `TableCellNode.getDOMSlot` keeps the cell's children before the overlay with `withBefore`, so DOM child offsets still match the node's children. The overlay is never part of `createDOM`, so exported HTML is unchanged. - Drag caret (`LexicalTableIOSDragCaret`): during a long press drag across cells, iOS keeps moving the native caret while the table selection keeps clearing it, so it flickers. The root's `caret-color` is made transparent while a finger is down on a cell and restored (to any previous inline value) when the last finger lifts. This reduces the flicker; the caret iOS draws around its magnifier is not affected by `caret-color`. Both are registered from `registerTableSelectionObserver` on iOS only. Non-iOS behavior and DOM are unchanged. Closes meta#9347 ## Test plan `IosEmptyCellOverlay.test.ts` and `IosTableDragCaret.test.ts` mock `IS_IOS`. ### Before With the sources at `main`: ``` $ pnpm exec vitest run packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts packages/lexical-table/src/__tests__/unit/IosTableDragCaret.test.ts × hides the caret while a finger is down on a cell × keeps hiding until the last finger lifts × restores a caret-color that was already set × a touch tap in an empty cell covers it for the double-tap window × restores the cell position when the overlay goes away × only the most recently tapped cell is covered × a second tap on the overlay places the caret in its cell × keeps managed children before the overlay and drops it once the cell has text Tests 8 failed | 8 passed (16) ``` On an iPhone (iOS Safari) with the playground: double tapping an empty cell flashes the cells above and the end of the paragraph above the table; a long press drag across cells starting from an empty cell paints the cells with the caret flickering throughout. ### After ``` $ pnpm exec vitest run packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts packages/lexical-table/src/__tests__/unit/IosTableDragCaret.test.ts Tests 16 passed (16) $ pnpm exec vitest run packages/lexical-table Test Files 30 passed (30) Tests 287 passed (287) $ pnpm exec vitest run --project browser packages/lexical-table/src/__tests__/browser Test Files 7 passed (7) Tests 58 passed (58) $ pnpm exec vitest run scripts/__tests__/unit/treeShakingSource.test.ts Tests 342 passed (342) $ pnpm run tsc # 0 errors $ pnpm run flow # Found 0 errors ``` On the same iPhone with the playground: double tapping an empty cell (repeated, at varying speeds) shows no highlight; a single tap places the caret and opens the keyboard; typing (including Korean) works; a long press in an empty cell keeps the native behavior; a long press drag starting from an empty cell paints the cells, with the caret flicker reduced but not gone; tapping the start cell right after a drag places the caret normally. An on-device event log confirmed the second tap of a double tap lands on the overlay. Not exercised: iPadOS, Android (code is iOS-only), and hardware keyboard navigation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
On iOS, double-tapping an empty table cell can create a native selection reaching into surrounding content without dispatching a second pointer event. Table selection normalization expands that range, so typing or pressing Backspace deletes the table and surrounding text.
Remember the tapped cell through pointerup and restore the previous caret when a native range escapes a cell composed of empty blocks, including multiple empty paragraphs. Clear that state on another pointer action, drag, cancellation, keyboard input, or blur. Preserve programmatic selections, existing ranges, and selections from cells containing text.
Closes #9266
Test plan
Add 30 (synthetic) browser regression tests that replay the reported DOM selection through the document selectionchange handler. Cover both selection directions, multiple empty paragraphs, synthesized double-click events, cell DOM endpoints, subsequent typing and Backspace, and controls for intentional selection and gesture cleanup. The controls include text elsewhere in the same cell, programmatic cross-cell ranges, and keyboard events whose propagation is stopped at the root.