Skip to content

[lexical] Bug Fix: Detect iPadOS desktop-class user agents - #8909

Merged
etrepum merged 2 commits into
meta:mainfrom
corinthionia:fix/ipados-is-ios-detection
Aug 5, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
corinthionia:fix/ipados-is-ios-detection

Conversation

@corinthionia

@corinthionia corinthionia commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

IS_IOS currently only matches when navigator.userAgent contains iPad, iPhone, or iPod.

On the physical iPad tested, both Safari and a React Native app using react-native-webview without a custom user agent reported a desktop-class Macintosh user agent with navigator.maxTouchPoints of 5, while a real Mac reported 0.

As a result, IS_IOS evaluates to false when iPadOS presents a desktop-class Macintosh user agent, preventing existing iOS-specific input handling from running.

This change identifies a Macintosh user agent with navigator.maxTouchPoints > 1 as iPadOS.

Side-effect review

Every current internal use of IS_IOS in this repository was reviewed.

The remaining internal uses continue to behave as before because they are already gated by IS_SAFARI or IS_APPLE_WEBKIT.

Behavior changes in the following areas:

  • Backspace handling in lexical-plain-text
  • Backspace handling in lexical-rich-text
  • LexicalEvents.ts handling of non-collapsed targetRange values during deleteContentBackward
  • LexicalEvents.ts handling of insertParagraph when inputState.isInsertLineBreak is set
  • LexicalEvents.ts compositionend timing

The compositionend path was verified manually on a physical iPad using the Japanese Romaji IME, which emits composition events.

Test plan

Before

On a physical iPad:

  • navigator.userAgent contained Macintosh
  • navigator.maxTouchPoints was 5
  • IS_IOS evaluated to false
  • During Korean IME input, the non-collapsed targetRange provided by beforeinput was ignored because IS_IOS evaluated to false, causing Lexical to fall through to DELETE_CHARACTER_COMMAND.
  • As a result, Backspace deleted a whole Hangul syllable instead of the last jamo. Continuing to type could then reintroduce characters from the deleted syllable. For example, while composing 가나다, pressing Backspace deleted the entire final syllable, typing ㄹ produced 가달, and completing the syllable resulted in 가다라 instead of the expected 가나라.

After

Automated verification:

  • Added environment.test.ts coverage for:
    • iPhone
    • iPad
    • Desktop-class Macintosh user agent with multi-touch
    • maxTouchPoints boundary (1 vs 2)
    • Real Mac (0)
    • Non-Apple touch device
  • Environment tests: 7 passed
  • Full unit suite: 228 test files, 4,945 passed, 1 skipped
  • ESLint passed
  • Prettier passed

Manual verification on a physical iPad using Safari on iPadOS 26.5.2:

  • Rich Text with the on-screen Korean keyboard
    • During Korean IME composition:
      • 가나다 → Backspace → 가낟
      • Continuing to type did not reintroduce deleted characters
  • Plain Text with the on-screen Korean keyboard
    • During Korean IME composition:
      • 가나다 → Backspace → 가낟
      • Continuing to type did not reintroduce deleted characters
  • Bluetooth keyboard with Korean input
    • Verified Backspace, Space, Enter, arrow keys, and Korean/English switching
    • Only beforeinput events were observed; no composition events were emitted
  • On-screen Japanese Romaji keyboard
    • Verified compositionstart, compositionupdate, and compositionend
    • nihon → 日本 → Backspace → re-enter hon
    • No duplicated, dropped, or replaced characters were observed
  • iPhone
    • Regression-checked typing, Backspace, and Enter
    • No behavioral changes were observed

iPadOS may expose a Macintosh user agent, causing IS_IOS to evaluate
to false. Detect these environments using multi-touch support while
keeping macOS and non-Apple touch devices classified as non-iOS.

Add unit coverage for classic iOS user agents, iPadOS desktop-class
user agents, multi-touch boundaries, and false-positive cases.
Improve iPadOS environment tests.

- Reuse the same Macintosh user agent fixture for iPadOS and macOS scenarios to isolate maxTouchPoints as the distinguishing signal.
- Restore navigator properties after each test to avoid leaking mocked accessors across test cases.
@vercel

vercel Bot commented Aug 3, 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 Aug 3, 2026 3:03pm
lexical-playground Ready Ready Preview Aug 3, 2026 3:03pm

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 Aug 3, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Aug 3, 2026
@etrepum
etrepum added this pull request to the merge queue Aug 5, 2026
Merged via the queue into meta:main with commit dee1b2c Aug 5, 2026
44 checks passed
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 408a4038 Deployed Aug 3, 2026 by vercel[bot]
Preview – lexical-playground — 408a4038 Deployed Aug 3, 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.

2 participants