Skip to content

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

Merged
ajpinedam merged 2 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/fix.wasm.textbox.touch.selection
Aug 22, 2026
Merged

ajpinedam merged 2 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/fix.wasm.textbox.touch.selection

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Aug 18, 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.

@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 18, 2026
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228301 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • Buttons.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ClipboardTests.png-dark
    • ListViewHeaderUpdate.png-dark
    • Examples.png-dark
  • skia-windows-screenshots: 2348 changed over 2396

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png
    • ApplicationViewSpanningRectsPage.png
    • AppWindowTitleBar Properties.png
    • AutoBorderStretchwithbottommargin.png
    • AutoSizedTopLeft.png-dark
    • AutoSuggestBox_SoftKeboard.png-dark
    • BasicThemeResources.png-dark
    • BorderBottomwithmargins.png
    • BorderLeftwithmargins.png
    • BorderRightwithmargins.png-dark
    • Border_Clipped_Change_Property.png
    • Border_CornerRadius.png-dark
    • Border_LinearGradientBrush.png
    • Border_Simple.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Canvas_In_Canvas.png-dark
    • Canvas_In_Canvas.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@ajpinedam
ajpinedam marked this pull request as ready for review August 18, 2026 13:29
Copilot AI lite review requested due to automatic review settings August 18, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via navigator (userAgent/platform/maxTouchPoints), with safe fallback to Other on probing failure.
  • Update Skia TextBox to choose Android/iOS touch-selection conventions based on BrowserHost when 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.

Copilot AI review requested due to automatic review settings August 18, 2026 13:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228410 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • ClipboardTests.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
    • Buttons.png-dark
    • Buttons.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
  • skia-windows-screenshots: 2348 changed over 2396

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AutoBorderStretchwithrightmargin.png
    • AutoSuggestBox_Description.png
    • BadgeNotificationTests.png-dark
    • BasicEnability.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Sizing.png-dark
    • Border_Clipped_Change_Property.png-dark
    • Border_Corner_Overlap.png
    • Border_LinearGradientBrush.png-dark
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • Button_UseUWPDefaultStyles.png-dark
    • Button_UseUWPDefaultStyles.png
    • CheckBox_Button_UWA_Style.png-dark
    • CheckBox_Button_UWA_Style.png
    • ColorAnimation_Fill.png-dark
    • ColorAnimation_Fill.png
    • ComboBox_FullScreen_Popup.png-dark
    • ComboBox_FullScreen_Popup.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

Copilot AI review requested due to automatic review settings August 18, 2026 15:34
@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.wasm.textbox.touch.selection branch from 935a98e to 944bcac Compare August 18, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Android is 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.Parse will throw an exception (failing the test with an error rather than a clean assertion) if someone edits the DataRow values incorrectly. Switching to Enum.TryParse produces 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));

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228441 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ImageIconPage.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • Gamepad_CurrentReading.png-dark
  • skia-windows-screenshots: 2348 changed over 2396

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AppWindowPresenters.png-dark
    • ArcSegment.png
    • AutomationPropertiesExtensions_Role.png
    • AutoSuggestBox_Icons.png
    • Basics_Automated.png
    • BezierSegment.png-dark
    • BitmapIcon_Generic.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • Border_Clipped_Change_Property.png
    • Border_CornerRadius.png-dark
    • Border_Simple_No_Background.png-dark
    • Border_Simple_No_Background.png
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Canvas_ZIndex.png-dark
    • Canvas_ZIndex.png
    • Clipping652.png-dark
    • Clipping652.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools

@SergioAlmeida29 SergioAlmeida29 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings August 21, 2026 01:57
@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.wasm.textbox.touch.selection branch from 944bcac to c88550f Compare August 21, 2026 01:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229069 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DisplayInformation.png-dark
    • ImageIconPage.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Focus_FocusVisual_Properties.png-dark
    • Image_AnimatedWebP.png-dark
    • Image_AnimatedWebP.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
  • skia-windows-screenshots: 2348 changed over 2396

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png
    • AppBarToggleButtonTest.png-dark
    • AppBar_KeyBoard.png-dark
    • AppBar_KeyBoard.png
    • ApplicationViewMode.png
    • Accessibility_ScreenReader.png
    • AnimatedIconPage.png-dark
    • ApplicationViewSizing.png
    • AutoBorderStretchwithtopmargin.png
    • AppWindowClosing.png
    • AppWindowFeatures.png
    • AppWindowPresenters.png
    • AppWindowPositionAndSize.png
    • ApplicationViewSizing.png-dark
    • AppXamlDefinedResources.png-dark
    • AutoSuggestBox_Description.png-dark
    • Attributed_text_Simple.png
    • Attributed_text_FontSize_Changing.png
    • Attributed_text_Supserscript.png-dark
    • Arrange_Performance01.png-dark
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • UITests.Uno_Web.Http.CookieManagerTests
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected

@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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

  • Queue this pull request

@ajpinedam
ajpinedam merged commit 7b58a47 into unoplatform:master Aug 22, 2026
48 checks passed
@ajpinedam

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

kazo0 added a commit that referenced this pull request Aug 28, 2026
…6.7/pr-24097

fix(textbox): Use mobile touch selection in mobile browsers (backport #24097)
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.

6 participants