Repository navigation
[lexical] Bug Fix: Limit handled selection input suppression to macOS Chrome - #9251
Merged
etrepum merged 1 commit intoSep 27, 2026
Merged
Conversation
… Chrome ## Description The workaround for meta#8416 suppresses the next nonempty insertText after a handled Backspace or select-all on every platform. An insertion without an intervening keydown, arriving before the zero-delay timer, is silently discarded and can collapse the selected range. Only arm the workaround on desktop Apple Chromium browsers (IS_APPLE && !IS_IOS && IS_CHROME). Other platforms process the insertion normally. Add regression tests covering both commands across Android, desktop, and iOS platform flags, including preservation of the macOS Chrome workaround. Assert editor text, DOM text, and the resulting caret rather than relying on defaultPrevented alone. This is the targeted mitigation proposed in the issue. A legitimate insertion in the same window on macOS Chrome remains indistinguishable from the unwanted native replacement and can still be suppressed. Closes meta#9250 ## Test plan ### Before pnpm exec vitest run --project unit packages/lexical/src/__tests__/unit/LexicalHandledSelectionInsertText.test.ts ``` AssertionError: expected 'draf' to be 'drafswift' // Object.is equality AssertionError: expected 'draft' to be 'swift' // Object.is equality Test Files 1 failed (1) Tests 10 failed | 4 passed (14) ``` ### After The same regression command: ``` Test Files 1 passed (1) Tests 14 passed (14) ``` pnpm exec vitest run --project unit packages/lexical/src/__tests__/unit/LexicalHandledSelectionInsertText.test.ts packages/lexical/src/__tests__/unit/LexicalEventsKeyDown.test.ts packages/lexical/src/__tests__/unit/LexicalEventsKeyDownApple.test.ts packages/lexical/src/__tests__/unit/IosEnterAcceptanceBoundary.test.ts packages/lexical/src/__tests__/unit/environment.test.ts ``` Test Files 5 passed (5) Tests 25 passed (25) ``` TypeScript (tsconfig.test.json), ESLint and Prettier checks passed. Also replayed the issue's collapsed-caret synthetic sequence in Chromium using navigator profiles: Android Backspace changes draf to drafswift; Android, iPhone and desktop-UA iPadOS select-all change draft to swift. The macOS Chrome profile still suppresses both immediate insertions. DOM and editor-state text agree in each case. These are emulated profiles, not physical-device tests; native macOS system text replacement was not exercised.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
September 27, 2026 21:39
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
September 27, 2026 21:39
trueadm
approved these changes
Sep 27, 2026
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
The workaround for #8416 suppresses the next nonempty insertText after a handled Backspace or select-all on every platform. An insertion without an intervening keydown, arriving before the zero-delay timer, is silently discarded and can collapse the selected range.
Only arm the workaround on desktop Apple Chromium browsers (IS_APPLE && !IS_IOS && IS_CHROME). Other platforms process the insertion normally. Add regression tests covering both commands across Android, desktop, and iOS platform flags, including preservation of the macOS Chrome workaround. Assert editor text, DOM text, and the resulting caret rather than relying on defaultPrevented alone.
This is the targeted mitigation proposed in the issue. A legitimate insertion in the same window on macOS Chrome remains indistinguishable from the unwanted native replacement and can still be suppressed.
Closes #9250
Test plan
Before
pnpm exec vitest run --project unit packages/lexical/src/tests/unit/LexicalHandledSelectionInsertText.test.ts
After
The same regression command:
pnpm exec vitest run --project unit packages/lexical/src/tests/unit/LexicalHandledSelectionInsertText.test.ts packages/lexical/src/tests/unit/LexicalEventsKeyDown.test.ts packages/lexical/src/tests/unit/LexicalEventsKeyDownApple.test.ts packages/lexical/src/tests/unit/IosEnterAcceptanceBoundary.test.ts packages/lexical/src/tests/unit/environment.test.ts
TypeScript (tsconfig.test.json), ESLint and Prettier checks passed.
Also replayed the issue's collapsed-caret synthetic sequence in Chromium using navigator profiles: Android Backspace changes draf to drafswift; Android, iPhone and desktop-UA iPadOS select-all change draft to swift. The macOS Chrome profile still suppresses both immediate insertions. DOM and editor-state text agree in each case. These are emulated profiles, not physical-device tests; native macOS system text replacement was not exercised.