Repository navigation
fix(wasm): iPad soft-keyboard focus (dismiss, LostFocus, bring-into-view) (backport #23890) - #24251
Merged
kazo0 merged 8 commits intoAug 28, 2026
Merged
Conversation
3 of 5 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-24251/wasm-skia-net9/index.html |
Contributor
|
The build 230676 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: Associated with an internal tracking issue (customer-reported).
PR Type:
🐞 Bugfix
What changed? 🚀
Fixes focus-related bugs specific to the Skia WebAssembly head on touch devices (iPad Safari/Chrome). They stem from the single shared, invisible
<input id="uno-input">that is positioned over the one<canvas>used for all text entry. None of them affect WinUI or the native (non-Skia) heads.1. Soft keyboard opens on a
TextBoxtap, then immediately dismisses itself.Touch browsers synthesize a trailing compatibility
mousedownafter a tap's focus change; it lands on the non-focusable canvas and its default action blurs the just-focused#uno-input, closing the keyboard. Uno alreadypreventDefaults pointer events, but per the Pointer Events spec that does not suppress the synthesized mouse-compatibility events. Fix: a one-shot, touch/pen-scoped guard that swallows the single trailing canvasmousedown/clickfollowing the input'sfocusin(armed on focus, disarmed on the nextpointerdown). Desktop mouse is unaffected — theremousedownprecedes focus, so the guard never arms.2.
LostFocusnever fires when the keyboard is dismissed this way.Focus was driven one-way (managed → native): nothing listened for the browser blurring
#uno-inputon its own, soFocusManagerstayed out of sync andLostFocusnever fired. Fix: ablurlistener on the input reports genuine, browser-initiated blurs to a newOnNativeBlurexport, which callsTextBox.Unfocus()— the same terminal focus-clearing path the iOS and native WASM heads already use. Managed-initiated blurs are suppressed so a focus switch never clears the wrong control.3. A focused field near the bottom is not scrolled above the keyboard.
The Skia WASM head had no
InputPaneproducer — nothing ever setInputPane.OccludedRect, so the shared bring-into-view path never ran. Fix: avisualViewportlistener computes the keyboard occlusion (gated on the invisible input being focused, so browser-chrome resizes don't count) and feedsInputPane.OccludedRect, mirroring the iOS/Android heads. This also makesInputPane.Showing/Hidingfire on this head, matching the other platforms.Follow-up fixes from on-device testing feedback
4. Bring-into-view could leave the focused field partially (or fully) behind the keyboard — e.g. inside a side panel with its own
ScrollViewer.Three compounding defects in the shared occlusion-padding path (
__SKIA__; the consuming code, not the new producer):ScrollContentPresenter.Padreduced the padding by the space below the focused element inside the viewport, so the minimalBringIntoViewlanded the element exactly that gap below the keyboard top. It now pads the full occluded overlap — which is what the Android head has always done (it passedRect.Empty), so the parameter is gone and both platforms share one behavior.OnBringIntoViewRequestedpath subtracted_occludedRectPadding.Bottomfrom the viewport on__SKIA__as well as__ANDROID__. On Skia the padding flows throughScrollViewer.Padding→ presenterMargin, whichViewportHeightalready reflects — subtracting again double-counted. Now Android-only (there the padding goes to the native view, invisible to managed layout).InputPane.skia.csnow keeps the pad applied across re-pads of the same presenter (Padcompensates internally), settles layout before measuring and beforeStartBringIntoView, and only restores when the target presenter changes or the pane hides. Restoring now puts back the app's originalPaddinginstead of resetting it to zero.5. Tapping another
TextBoxwhile the keyboard is up dismissed it.Moving focus A→B destroyed the shared input (
EndEntry(A)blurred + removed it) beforeStartEntry(B)recreated it — a "nothing editable focused" gap that commits the soft-keyboard dismissal on iPadOS. Reworked lifecycle:focus()now retargets the existing input in place (value,inputmode,enterkeyhint) when the element kind matches — it never blurs, so the keyboard stays up.EndEntry) defers the real detach by one microtask; thefocus()of a TextBox-to-TextBox move supersedes it. Genuine dismissals (tap outside, Done key) detach as before.Blurnow carries the owning TextBox's handle so a stale blur can never tear down a successor's entry session, and the retarget path re-arms the fix-1 guard (it fires nofocusin).Drive-by:
updateSize()set the invisible input'swidth/heightwithoutpxunits, so the styles were ignored; the input rect is what Safari uses as its scroll-reveal target, so it now gets real dimensions.Validation
SamplesApp.Skia.WebAssembly.Browserapp (TS + C#).Given_InputPane.When_Focused_TextBox_Has_Content_Below_Then_Scrolled_Above_Occlusion— the reported side-panel geometry distilled: old code left the field ~38 px under the keyboard; now asserts the field rect ends fully above the occlusion.Given_InputPane.When_OccludedRect_Cleared_Then_ScrollViewer_Padding_Restored— app-setScrollViewer.Paddingsurvives an occlusion cycle (additive pad, restore on clear).Given_InputPane.When_OccludedRect_Set_Then_Focused_TextBox_Scrolled_Into_Viewstrengthened with the same geometric assertion.Given_ScrollViewer/Given_ScrollViewer_Zoomruntime tests pass (outside keyboard scenarios the removed subtraction was always zero).Given_TextBoxruntime suite executed on Skia WASM in a browser — 148 passed / 27 skipped, and the only 2 failures are sub-pixel rounding assertions that fail byte-identically on a baseline build without these changes (pre-existing, environment-specific).SoftKeyboardFocusTests(GotFocus/LostFocus counters, liveOccludedRectreadout, bottom field). Fixes 1, 2, and 5, and the on-device occlusion math, reproduce only on a real iPad, so final device validation there is still required — this PR is a draft pending that.Padkeeps Android's existing full-intersection behavior; the additive padding and restore-on-clear are shared improvements validated by code review + the Skia runtime tests (no Android runtime run here).Known remaining item from the same feedback (tracked for a follow-up): Safari auto-pans its visual viewport to reveal the DOM input when it sits below the keyboard, which can fight the XAML-level scroll (most visible with the taller multi-tab Safari header) and let the whole page pan instead of inner ScrollViewers.
PR Checklist ✅
Screenshots Compare Test Runresults.This is an automatic backport of pull request #23890 done by [Mergify](https://mergify.com).