Skip to content

fix(textbox): Use mobile touch selection in mobile browsers (backport #24097) - #24252

Merged
kazo0 merged 2 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24097
Aug 28, 2026
Merged

kazo0 merged 2 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24097

Conversation

@mergify

@mergify mergify Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: n/a — customer-reported, tracked internally.

PR Type:

🐞 Bugfix

What changed? 🚀

Current behavior: in a WebAssembly app using the Skia renderer, editable text controls always used the Desktop touch-selection convention, even when the browser runs on a phone or a tablet. On an iPad that means a single tap selects a word instead of placing the caret, a double-tap does not select the word under the finger, and a long-press opens the context flyout instead of the iOS caret drag. It affects TextBox, multiline TextBox, PasswordBox and NumberBox alike.

The Skia TextBox already implements the native iOS/Android touch conventions (word select on double-tap, insertion/selection grippers, iOS caret drag on long-press, the copy/paste selection flyout). Only the default was wrong: GetDefaultTouchTextSelectionConvention() resolved it from OperatingSystem.IsAndroid() / DeviceTargetHelper.IsUIKit(), and both are false in a browser — the OS APIs only ever report "browser", never the device underneath.

This PR adds DeviceTargetHelper.BrowserHost, which detects the OS hosting the browser once per process from navigator.userAgent, navigator.platform and navigator.maxTouchPoints, and makes the touch-selection convention honor it: iOS/iPadOS browsers get the iOS convention, Android browsers the Android one, desktop browsers stay on Desktop as before.

The iPadOS 13+ wrinkle is worth calling out: iPad browsers request the desktop site by default and report a Mac user agent and navigator.platform === "MacIntel", so touch capability is the only thing that tells an iPad apart from a Mac. A touchscreen alone does not switch a desktop OS to mobile conventions — WinUI itself doesn't. If probing navigator fails (e.g. a Content-Security-Policy without unsafe-eval), detection falls back to Other, i.e. exactly today's behavior.

Note that the browser's own selection UI (Safari's loupe, its handles and edit menu) is not what this restores, and cannot be: the Skia canvas sets touch-action: none so Uno receives every pointer event, and the text input backing it is invisible and pointer-events: none. Uno draws the platform-equivalent selection UI instead, which is what this PR makes appear on tablets and phones.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
    • Given_DeviceTargetHelper.When_GetBrowserHostPlatform covers the detection over real user agents: iPad requesting the desktop site, iPad requesting the mobile site, Chrome on iPad, iPhone, Android phone, Android tablet, Safari on macOS, a Windows touch device, Windows/Linux desktop, and an unavailable navigator.
    • The behavior each convention drives is already covered by the existing Given_TextBox touch tests (When_Touch_DoubleTap_Selects_Word_iOS, When_Touch_SingleTap_Places_Caret_iOS, When_Touch_LongPress_*, …). Those inject touch through InputInjector and are gated to SkiaDesktop | SkiaAndroid, so they cover the conventions themselves but not the browser; the browser side was validated manually: the published SamplesApp.Skia.WebAssembly.Browser served over LAN and opened on an iPad in Safari — single tap places the caret, double-tap selects the tapped word with grippers and the copy/paste bar, long-press drags the caret.
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes

Behavior change to be aware of: WebAssembly Skia apps opened on Android phones/tablets and on iPhones now follow those platforms' touch text-selection conventions too, matching the native Skia Android/iOS targets.


This is an automatic backport of pull request #24097 done by [Mergify](https://mergify.com).

@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/automation Categorizes an issue or PR as relevant to project automation labels Aug 27, 2026
@kazo0

kazo0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230675 did not find any UI Test snapshots differences.

@mergify

mergify Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@kazo0
kazo0 merged commit 55ae144 into release/stable/6.7 Aug 28, 2026
48 checks passed
@kazo0
kazo0 deleted the mergify/bp/release/stable/6.7/pr-24097 branch August 28, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants