Repository navigation
Conversation
|
The build 228301 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
This PR updates Skia TextBox touch-selection defaults so WebAssembly apps running in mobile browsers (iOS/iPadOS/Android) use the corresponding mobile selection conventions, instead of always falling back to Desktop due to OperatingSystem.IsAndroid()/IsIOS() being false in browsers.
Changes:
- Add
DeviceTargetHelper.BrowserHost(cached) to detect the OS hosting the browser vianavigator(userAgent/platform/maxTouchPoints), with safe fallback toOtheron probing failure. - Update Skia
TextBoxto choose Android/iOS touch-selection conventions based onBrowserHostwhen running in WebAssembly. - Add unit tests covering representative user-agent/platform combinations (including iPadOS “desktop site” behavior).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs | Uses DeviceTargetHelper.BrowserHost to select iOS/Android touch-selection conventions in mobile browsers. |
| src/Uno.UI/Helpers/DeviceTargetHelper.cs | Adds cached browser-host OS detection with fallback/logging when navigator probing fails. |
| src/Uno.UI/Helpers/BrowserHostPlatform.cs | Introduces the BrowserHostPlatform enum used for browser-host OS detection. |
| src/Uno.UI.UnitTests/Helpers/Given_DeviceTargetHelper.cs | Adds data-driven unit tests validating browser-host OS detection across common UA/platform scenarios. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24097/wasm-skia-net9/index.html |
|
The build 228410 found UI Test snapshots differences: Details
|
935a98e to
944bcac
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/Uno.UI/Helpers/DeviceTargetHelper.cs:53
- PR description doesn’t meet the repo’s mandatory issue-linking format. If there’s intentionally no public GitHub issue, the description should include the standard note (e.g. “Note: No related issue (Internal maintenance / Approved by Team member: @).”) so it’s clear this is intentionally unlinked.
/// <summary>
/// The mobile OS hosting the browser, for features that must follow the host device's interaction
/// conventions: on WebAssembly the OS APIs only ever report "browser", never the underlying device.
/// </summary>
internal static BrowserHostPlatform BrowserHost => _browserHost.Value;
src/Uno.UI/Helpers/BrowserHostPlatform.cs:19
BrowserHostPlatform.Androidis missing an XML doc comment while the other enum values are documented. Adding a brief summary keeps the enum documentation consistent and helps avoid ambiguity when it shows up in IntelliSense.
/// <summary>
/// iOS or iPadOS, whichever browser engine is in use (they are all WebKit on those platforms).
/// </summary>
iOS,
Android,
}
src/Uno.UI.UnitTests/Helpers/Given_DeviceTargetHelper.cs:41
- Using
Enum.Parsewill throw an exception (failing the test with an error rather than a clean assertion) if someone edits the DataRow values incorrectly. Switching toEnum.TryParseproduces a clearer test failure message and keeps the failure mode as an assertion.
public void When_GetBrowserHostPlatform(string userAgent, string platform, bool isTouchCapable, string expected)
=> Assert.AreEqual(
Enum.Parse<BrowserHostPlatform>(expected),
DeviceTargetHelper.GetBrowserHostPlatform(userAgent, platform, isTouchCapable));
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24097/wasm-skia-net9/index.html |
|
The build 228441 found UI Test snapshots differences: Details
|
SergioAlmeida29
left a comment
There was a problem hiding this comment.
LGTM, fix is well-isolated, the 11 new unit test cases all pass locally.
Minor note:
maxTouchPoints > 0 is used where some implementations use > 1.
It shouldn't matter in practice since non-touch Macs report 0, but worth double-checking there's no edge case with external touch displays.
944bcac to
c88550f
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24097/wasm-skia-net9/index.html |
|
The build 229069 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
…6.7/pr-24097 fix(textbox): Use mobile touch selection in mobile browsers (backport #24097)
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.