Skip to content

fix(ios): reliable touch selection, selection menu taps, and lossy text decoding - #3146

Open
deadlyjack wants to merge 8 commits into
mainfrom
ajit/ios-touch-menu-fix
Open

deadlyjack wants to merge 8 commits into
mainfrom
ajit/ios-touch-menu-fix

Conversation

@deadlyjack

@deadlyjack deadlyjack commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes text selection and the touch selection menu reliable on iOS, and fixes a few iOS issues along the way.

Touch pointers WebKit leaves down

WebKit sends pointerdown, then never sends pointerup or pointercancel, when a native gesture takes over a touch (dragging a selection handle, double-tapping a word). The editor kept thinking a finger was down and hid the selection menu until the next touch.

  • New WebTouchEnd watches touches natively without blocking or delaying any gesture. When the last finger lifts, it sends pointercancel to the page and its frames for every touch pointer still held. It waits a short moment first, so a real pointerup that arrives late still wins.
  • The recognizer never puts itself into a failed state. WebKit doesn't reset a failed recognizer while its double-tap recognizer is pending, so it used to miss the second tap.
  • It is installed in both the main and the preview WebViews, and it keeps working if a touch-end is missed.

Selection menu

  • Menu buttons activate on touchend, with a 100 ms fallback. Removing the menu can no longer swallow the touchend and let WebKit move the caret under the finger. Buttons also accept WebKit's emulated mousedown when a tap never reports pointerup.
  • The menu puts back a selection that WebKit's native text tap moved or cleared behind a press. This lasts at most 1.5 s, is dropped if the press is cancelled, and ends on any tap outside the menu or any key press in the editor. Menu actions that change the selection keep their own result.
  • This tap guard only runs on iOS.
  • Copying on iOS shows a confirmation toast.
  • Insert color only appears when the caret or selection is on a color. It checks the menu's own pane and inserts into that pane, so split panes stay in sync (merged with fix(editor): insert color into the tapped split pane #3149).

Text decoding

FileContents.decode now handles malformed bytes the way Android does: they become U+FFFD instead of the whole decode failing. A UTF-8 BOM is stripped.

Tests and CI

  • Unit tests cover the touch-end bridge, the menu button activation, the tap guard and getColorRange. Native tests cover WebTouchEnd and FileContents.
  • Flaky hosted-simulator tests are more tolerant of a slow first load:
    • PreviewTransferTests retries the initial preview load once.
    • BridgeTestCase waits up to 90 s for the app WebView on a cold start.
  • docs/ios-port.md documents the touch-end and tap-guard behaviour.
  • Version bumped to 1.13.8 (1027).

🤖 Generated with Claude Code

…ture

WebKit delivers pointerdown but never pointerup or pointercancel when a native gesture claims a touch, such as dragging a text selection handle or double-tapping a word, so the editor kept believing a finger was down and hid the selection menu until the next touch. WebTouchEnd now observes touches natively without preventing or delaying any gesture; when the last finger lifts, pages and their frames receive a pointercancel for the touch pointers still held, after a short settle window so a real pointerup that arrives late wins. The recognizer never fails itself, because a failed recognizer is not reset while WebKit's double-tap recognizer is pending, which made it miss the second tap. It is installed in the main and preview WebViews, and it tolerates a missed touch-end instead of silencing itself.

Selection menu buttons now activate on the touch's touchend, with a 100 ms fallback, so removing the menu cannot drop touchend and let WebKit place the caret under the finger, and they accept WebKit's emulated mousedown when a tap never reports pointerup. The menu also restores the selection that WebKit's native text tap moves or clears behind a press, bounded to 1.5 s and dropped when the press is cancelled. Copying on iOS shows a confirmation toast, and the colour action only appears when the caret or selection holds a colour, using the menu's own editor state so split panes no longer disagree.
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; the previous late-tap issue is fixed and no new blocking issues were found.

Summary

The PR repairs missing iOS touch releases and improves selection-menu taps. The latest change preserves selection protection when WebKit reports a cancelled tap through a late mousedown.

  • iOS WebViews cancel touch pointers WebKit leaves down.
  • Selection menu buttons wait for touch release before acting.
  • The iOS menu restores selections changed by a native text tap.
  • Copying or cutting text shows an iOS confirmation toast.
  • Insert Color appears only for a color in the menu's editor.
  • iOS decoding replaces malformed bytes with a replacement character.
  • Reopened selection menus keep their normal shape.
  • The release numbers and preview-load test setup are updated.

Reviews (4) · Last reviewed commit: "fix: Late taps lose selection protection" · Reviewed by Greptile

Comment thread src/cm/touchSelectionMenu.js Resolved
Comment thread src/cm/touchSelectionMenu.js Resolved
The guard that restores the selection after a menu press no longer outlives the press: any tap outside the menu and any key press in the editor clears it, so the following selection change belongs to the editor. A selection-changing menu action keeps its own selection, because the restore is skipped while an action runs. The docs now describe the guard's full lifetime, and tests cover a second press on the menu, an action that changes the selection, and the outside-tap and key-press cases.
@deadlyjack

Copy link
Copy Markdown
Member Author

@greptile

Ajit Kumar added 3 commits December 2, 2026 16:44
Cancel stale touch pointers after native gestures, activate menu buttons on touch end with WebKit fallbacks, and restore selections cleared by iOS native text taps. Gate the tap guard to iOS and keep touched buttons activatable after WebKit cancels the pointer.

Decode malformed text like Android instead of failing and cover the behaviour with tests. Bump the build number to 1027.
@deadlyjack

Copy link
Copy Markdown
Member Author

@greptile

Comment thread src/cm/selectionMenuUtils.ts Resolved
@deadlyjack

Copy link
Copy Markdown
Member Author

@greptile

Ajit Kumar and others added 2 commits December 3, 2026 20:52
Resolve conflicts with #3149: the menu now takes the tapped pane's view,
gates "insert color" on getColorRange(view.state), and passes the view to
insert-color, which reads the range from that view's state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first suite timed out after ~10s while a cold hosted simulator took
about a minute to finish the initial page load. Wait up to 90s instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@deadlyjack deadlyjack changed the title fix(ios): cancel touch pointers WebKit leaves down after a native ges… fix(ios): reliable touch selection, selection menu taps, and lossy text decoding Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant