Repository navigation
fix(wasm): Keep the hidden TextBox input off-screen on iOS - #24527
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate review findings affect test isolation, DOM coverage, and diagnostic accuracy.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Prevents iOS WebKit from panning the WASM app by parking Uno’s hidden text input off-screen while preserving desktop tracking.
Changes:
- Detects iOS/iPadOS and applies off-screen input placement.
- Uses
preventScrollduring focus transitions. - Adds regression coverage and expands the soft-keyboard sample.
File summaries
| File | Summary |
|---|---|
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs |
Adds desktop placement coverage. Requires cleanup isolation, issue metadata, and stronger DOM rectangle/size assertions. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/UI/Xaml/Controls/TextBox/BrowserInvisibleTextBoxViewExtension.cs |
Documents platform-specific input placement handling. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserInvisibleTextBoxViewExtension.ts |
Implements iOS off-screen placement and focus behavior. |
src/SamplesApp/SamplesApp.Samples/Windows/UI/ViewManagement/SoftKeyboardFocusTests.xaml.cs |
Adds focus and scroll diagnostics; the offset readout should update on scroll changes. |
src/SamplesApp/SamplesApp.Samples/Windows/UI/ViewManagement/SoftKeyboardFocusTests.xaml |
Adds side-panel keyboard and scrolling scenarios. |
Review details
Suppressed comments (3)
src/SamplesApp/SamplesApp.Samples/Windows/UI/ViewManagement/SoftKeyboardFocusTests.xaml.cs:48
- This readout is only refreshed when a field receives focus, so it shows the pre-scroll offset while
InputPanebrings a field into view and never changes during the drag in step 5. Subscribe toSidePanelScrollViewer.ViewChanged(and reuse this formatting) so the sample actually reports the panel's current offset during the scenarios it was added to diagnose.
PanelFocusTextBlock.Text = $"Focused field: {(string.IsNullOrEmpty(name) ? sender.GetType().Name : name)} Panel offset: {SidePanelScrollViewer.VerticalOffset:0}";
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:52
- This runtime test directly covers issue #24526, but it has no
GitHubWorkItemmetadata. The runtime-test conventions require issue-covering tests to carry the fully qualified issue URL so the regression remains traceable.
[TestMethod]
[RunsOnUIThread]
[PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.SkiaWasm)]
public async Task When_Focused_In_Browser_Then_Hidden_Input_Tracks_TextBox()
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:88
GetHiddenInputPositionreads only the inlinestyle.left/top; it does not verify the actual DOM rectangle WebKit uses, and it never checks thewidth/heightbehavior changed inupdateSize. A CSS offset or size regression could therefore pass this test. QuerygetBoundingClientRect()and assert x/y/width/height against the TextBox (with tolerance) in both placement checks.
var raw = InvokeBrowserJs("(function(){const e = document.getElementById('uno-input'); return e ? parseFloat(e.style.left) + ',' + parseFloat(e.style.top) : '';})()");
var parts = raw.Split(',');
return parts.Length == 2
&& double.TryParse(parts[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var x)
&& double.TryParse(parts[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var y)
? new Point(x, y)
: new Point(double.NaN, double.NaN);
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Address the two moderate placement-test assertion gaps before approval.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:70
RuntimeTestPlatforms.SkiaWasmcovers every browser-hosted Skia runtime, including desktop Chrome and iOS. This test takesplacementfrom the implementation and then uses that same value as the expected branch, so an incorrectly enabled iOS gate on desktop would reportoffscreenand still pass instead of pinning the desktop contract totracking. Derive the expected host policy independently (or keep the desktop assertion explicitlytracking) so this regression is detected.
await UITestHelper.WaitFor(() => GetHiddenInputPlacement() is "tracking" or "offscreen", timeoutMS: 3000, message: "hidden input created with a known placement");
var placement = GetHiddenInputPlacement();
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
Two unresolved moderate test issues must be addressed before approval.
Review details
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:70
- The test derives the expected branch from
data-uno-placementitself, so it does not independently verify the host gate: a regression that reportsoffscreenon desktop (ortrackingon iOS) would still pass as long as the input matches that self-reported policy. Compute the expected placement fromnavigator.platform/maxTouchPoints(or explicitly asserttrackingin the desktop run) before validating the rect, so the desktop contract described by this PR is actually pinned.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:68
- Please assert the return value of
Focushere. The test reads a shared DOM input, and the iOS branch only checks that it is off-screen; if focus fails while a previous test has left that shared input present, the stale off-screen element can satisfy both placement waits without proving that thisSUTowns the input.
SUT.Focus(FocusState.Programmatic);
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24527/wasm-skia-net9/index.html |
|
The build 234013 found UI Test snapshots differences: Details
|
|
Both points from the latest review are fixed in 8fb47d7 - the first one in particular was a fair hit on the test's premise. Self-referential assertion (line 70). Correct: the test read Unchecked Passing in headless Chrome. For the record on the earlier rounds: the previous CI red was a build my own push cancelled (cancelled in-flight jobs report as failures), and the snapshot-difference counts are identical on #24525, #24523, #24519 and #24509, so that baseline shifted on master rather than here - this change is browser-only TypeScript and its sample is |
There was a problem hiding this comment.
🔵 Needs a closer look
Platform-specific iOS/WebKit behavior and validation discrepancies warrant human review.
Review details
Suppressed comments (2)
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:54
- The PR checklist says the manual sample is the only test coverage and that the behavior is not reachable from runtime tests, but this diff adds a Skia WASM runtime test here. Please reconcile the checklist with the actual automated placement-policy coverage so the PR's validation record is accurate.
[TestMethod]
[RunsOnUIThread]
[PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.SkiaWasm)]
[GitHubWorkItem("https://github.com/unoplatform/uno/issues/24526")]
public async Task When_Focused_In_Browser_Then_Hidden_Input_Placement_Matches_Host()
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:54
- The PR description still names
Given_TextBox.When_Focused_In_Browser_Then_Hidden_Input_Tracks_TextBox, but this diff definesWhen_Focused_In_Browser_Then_Hidden_Input_Placement_Matches_Hostand covers both tracking and off-screen policies. Please update the description and validation references to the actual test name and scope so the documented test result is not stale.
public async Task When_Focused_In_Browser_Then_Hidden_Input_Placement_Matches_Host()
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24527/wasm-skia-net9/index.html |
|
Pushed 204f372 for the WASM runtime-test failure on the previous run, plus a correction to what I said about it. What CI actually reported. So the cause is not proven yet, and I am not going to guess again. This push does two things:
If it fails again, the message will name the failure mode instead of leaving it to inference. On the neighbours in that group: The Android group-0 failure in the same run was the agent failing to install the Android emulator ( |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24527/wasm-skia-net9/index.html |
|
Root cause found and fixed in bbc45f1. The diagnostics added in the previous push answered it on the first CI run: The active element was an accessibility semantic element. So it was never flakiness or a timeout - it was a missing precondition. Runs differed only in whether an accessibility test had run first, which is also why it reproduced on CI but never locally, where I was running the test alone or with the wrong neighbours. The test now branches on that environment fact, via the existing
Neither branch is a silent pass, and the branch is keyed on whether accessibility built a semantic element (an environment fact) rather than on what Verified locally in both configurations: alone (placement branch) and after For the record, the other failures in that run are not from this PR: |
4a8c08c to
f2cdde8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Accessibility-enabled TextBoxes still focus an on-screen semantic input, so iOS WebKit can continue to pan the fixed page.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24527/wasm-skia-net9/index.html |
|
The build 234610 found UI Test snapshots differences: Details
|
|
@Mergifyio backport servicing/6.8 |
✅ Backports have been createdDetails
|
…r-24527 fix(wasm): Keep the hidden TextBox input off-screen on iOS (backport #24527)
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
…6.7/pr-24527 fix(wasm): Keep the hidden TextBox input off-screen on iOS (backport #24527)
GitHub Issue: closes #24526
PR Type:
🐞 Bugfix
What changed? 🚀
Current behavior. On the Skia WebAssembly head in iPad/iPhone Safari (and any iOS browser, all WebKit), focusing a
TextBoxthat sits near or under the soft keyboard can shift the whole application up: WebKit scrolls the page into the keyboard inset to reveal the focused editable. The page isposition:fixedso nothing else can move, and the shift is not undone until focus is lost. While the page is shifted,clientX/Y(viewport-relative in Safari) no longer match the canvas, so every tap landspanpixels away from what the user sees: tapping a secondTextBoxfocuses something else and closes the keyboard, and one-finger drags inside aScrollViewerpan the page instead of scrolling the content. The internalInputPanebring-into-view (#23890) and WebKit's reveal also fight each other, so the focused field bobs in and out from under the keyboard.WebKit has two reveal paths (from
WKWebViewIOS.mm/WKContentViewInteraction.mm):_zoomToRevealFocusedElement(deferred to keyboard-will-show; centers the element when it is within 50pt of the keyboard) — this one honorsfocus({ preventScroll: true });_scrollToAndRevealSelectionIfNeededscrolls by exactlycaretBottom + 4 − visibleHeightwhen the caret was visible before the change — this one ignorespreventScroll.Both need an on-screen caret rect to act on. Uno's
TextBoxdraws its own caret, selection, touch grippers and selection flyout, so the shared invisible#uno-inputonly has to exist and be focused; its position on iOS is not used for anything the user can see.New behavior.
navigator.platformiP*, orMacIntelwithmaxTouchPoints > 1for iPadOS 13+),#uno-inputis created withtop: -10000px(left stays 0 so a right-to-left document gains no scrollable overflow) andupdatePosition/updateSizebecome no-ops there: a multi-lineTextBoxreports its full content height, which would otherwise stretch the input back into the viewport. WebKit finds nothing to reveal, the visual viewport never pans, and pointer coordinates stay aligned with the canvas. Other platforms keep the input placed and sized over theTextBox(desktop IME candidate windows anchor to it). The active policy is exposed asdata-uno-placement="offscreen|tracking"on the input for Web Inspector diagnosis.focus()is called with{ preventScroll: true }on both the retarget and the swap paths, on every platform: theInputPanedrives bring-into-view, the browser's scroll-to-focus is never wanted.SoftKeyboardFocusTestsmanual sample gains a side-panelScrollViewer(Title, numeric AutoNumber, dates, multiline notes, ten fields) with a focused-field/panel-offset readout, mirroring the customer layout. Items 4–5 also reproduce in the iOS Simulator (toggle I/O > Keyboard > Connect Hardware Keyboard to force a keyboard frame change).Given_TextBox.When_Focused_In_Browser_Then_Hidden_Input_Placement_Matches_Hostpins the placement policy on whichever browser hosts the suite. It derives the expected policy from the host rather than from what the page reports, then asserts the matching geometry:trackingmeans the input's rendered rect sits inside theTextBoxand follows it when it moves;offscreenmeans the rect stays entirely above the viewport across the same move. A missing input fails both branches.Validation.
SamplesAppserved over LAN, driven from the session. The pan was reproduced deterministically on the baseline by parking the input under the keyboard and changing the keyboard frame (Simulator hardware-keyboard toggle): page scrolls 125px,vv.offsetTop == scrollY == 125, a tap at the checkbox's visual position reportsclientY=123/pageY=498and toggles a control 375px away.preventScrollalone still pans 125px;scrollTo(0,0)counter-pan leaves a 3–8px visual-viewport offset JS cannot clear;line-height:0is ignored on<input>;width/height:0still pans (caret rect is not clipped);font-size:0works but risks the 16/fontSize focus zoom on iPhone; off-screen input: no pan, keyboard opens, typing works.visualViewport.offsetTopstays 0), typing reaches theTextBox, tapping a neighbouringTextBoxkeeps the keyboard open, dragging inside aScrollViewerscrolls it. Control run with the input forced back on-screen still pans.Given_TextBox.When_Focused_In_Browser_Then_Hidden_Input_Placement_Matches_Hostpasses on the Skia WASM head in headless Chrome, which exercises thetrackingbranch. Theoffscreenbranch runs the first time the suite is hosted on an iOS browser.PR Checklist ✅
Screenshots Compare Test Runresults — the reported differences (skia-linux 57, skia-windows 2310, wasm 11) are identical on perf(uno-ui): Reuse boxes on the inherited-property and hit-test paths #24525, perf(theming): Walk resource dictionaries without an iterator #24523, perf(uno-ui): Index DO collections in tree walks #24519 and fix: Refresh NavigationView ancestor selection #24509, so the baseline shifted on master. This change is browser-only TypeScript and its sample isIsManualTest/IgnoreInSnapshotTests, so it emits no snapshots.