Repository navigation
fix(textbox): Use mobile touch selection in mobile browsers (backport #24097) - #24252
Merged
kazo0 merged 2 commits intoAug 28, 2026
Merged
Conversation
2 of 4 tasks
ajpinedam
approved these changes
Aug 27, 2026
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24252/wasm-skia-net9/index.html |
Contributor
|
The build 230675 did not find any UI Test snapshots differences. |
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
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.
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, multilineTextBox,PasswordBoxandNumberBoxalike.The Skia
TextBoxalready 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 fromOperatingSystem.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 fromnavigator.userAgent,navigator.platformandnavigator.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 probingnavigatorfails (e.g. a Content-Security-Policy withoutunsafe-eval), detection falls back toOther, 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: noneso Uno receives every pointer event, and the text input backing it is invisible andpointer-events: none. Uno draws the platform-equivalent selection UI instead, which is what this PR makes appear on tablets and phones.PR Checklist ✅
Given_DeviceTargetHelper.When_GetBrowserHostPlatformcovers 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 unavailablenavigator.Given_TextBoxtouch tests (When_Touch_DoubleTap_Selects_Word_iOS,When_Touch_SingleTap_Places_Caret_iOS,When_Touch_LongPress_*, …). Those inject touch throughInputInjectorand are gated toSkiaDesktop | SkiaAndroid, so they cover the conventions themselves but not the browser; the browser side was validated manually: the publishedSamplesApp.Skia.WebAssembly.Browserserved 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.Screenshots Compare Test Runresults.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).