Repository navigation
[0.83] fix(textinput): show touch keyboard on focus and on tap (windowless island; re-tap reopens) - #16330
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
…terop for windowless island; re-tap reopens a dismissed keyboard)
9d61725 to
6d5d4a0
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses Fabric/Composition TextInput in WinAppSDK island (windowless RichEdit host) not invoking the Windows touch keyboard by explicitly requesting it via InputPane Win32 interop when the field is focused or tapped, enabling keyboard re-open on re-tap after dismissal.
Changes:
- Add a
ShowSoftKeyboard()helper to request the touch keyboard usingIInputPaneInterop::GetForWindow()andInputPane::TryShow(). - Invoke
ShowSoftKeyboard()from bothonGotFocusandOnPointerPressedto support initial focus and re-tap reopen scenarios. - Add a change file documenting the patch release.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h | Declares the new ShowSoftKeyboard() helper. |
| vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp | Implements keyboard invocation via InputPane interop and calls it on focus and pointer press. |
| change/react-native-windows-fix-textinput-touch-keyboard.json | Adds changelog entry for the fix. |
Suppressed comments (1)
vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp:1094
- The posture gate only checks
SM_CONVERTIBLESLATEMODE. On non-convertible desktops this metric commonly evaluates to 0 ("slate"), which would makeShowSoftKeyboard()attempt to show the touch keyboard in non-tablet environments. Also, requesting the keyboard wheneditable == falseis unexpected for a read-only TextInput.
// keyboard invocation break input handling.
if (::GetSystemMetrics(SM_CONVERTIBLESLATEMODE) != 0)
return;
auto root = rootComponentView();
if (!root)
return;
| // Tapping the field brings up the touch keyboard — including when the input is already | ||
| // focused (e.g. after the user dismissed the keyboard), which does not fire onGotFocus. | ||
| ShowSoftKeyboard(); |
|
Friendly bump — this has been open for a while without a decision. Is there anything you need from me to move it along (rebase onto current main, splitting it, extra tests)? Happy to update it either way. |
|
Thank you for your contribution! We deprecated support for 0.83 in RNW. Please consider to switch your app to 0.85. |
Fixes #16331.
Problem
On a Windows tablet with no physical keyboard, tapping a single-line
<TextInput>(e.g. a login field) never raises the touch keyboard. Additionally, after the keyboard is dismissed, re-tapping the (still-focused) field does not bring it back.Root cause
Fabric/Composition
TextInput(WindowsTextInputComponentView) has no code that requests the touch keyboard on focus —onGotFocusnever touchesInputPane/CoreInputView. In a WinAppSDK Win32 island app there is noCoreWindow, and the RichEdit is hosted windowless viaITextServices(no child edit HWND), so the OS's own touch-keyboard auto-invoke heuristic never fires either. Net: the keyboard never appears. (The UWP-era PR #2029 for this was closed and relied onGetForCurrentView()APIs that don't apply to the island model.)A tap on an already-focused field does not fire
onGotFocus, so a focus-only trigger can't re-raise a keyboard the user has dismissed.Fix
New helper
ShowSoftKeyboard()requests the touch keyboard viaInputPane, obtained through the Win32 interopIInputPaneInterop::GetForWindow()keyed off the island's top-level AppWindow HWND (rootComponentView()->GetHwndForParenting()). Gated on slate/tablet posture (SM_CONVERTIBLESLATEMODE == 0) so it does not pop on a laptop/convertible with a keyboard attached; wrapped intry/catchso it can never break input handling.It is called from both:
onGotFocus— raise the keyboard when the field gains focus, andOnPointerPressed— raise it on tap, so re-tapping an already-focused field reopens a dismissed keyboard.Focus is intentionally left untouched on keyboard dismissal (the field stays focused; the user reopens the keyboard by tapping it again — the platform-appropriate behavior here).
Uses
IInputPaneInteropfrom<inputpaneinterop.h>andwinrt::Windows::UI::ViewManagement::InputPane— both ship in the Windows SDK already referenced by Microsoft.ReactNative, so there are no.vcxproj/reference changes.Validation
Compiled into Microsoft.ReactNative from source (yarn-patch framework build,
UseExperimentalNuget=false) in a production RNW 0.83.2 new-arch app (Facilitron FIT), x64 Release, deployed to a physical x64 tablet. With the keyboard detached (Windows suppresses the touch keyboard while a hardware keyboard is attached):All three confirmed on-device. Remaining for upstream: CI build across archs.
Caveats for reviewers
0.83-stableto match our production app; happy to re-cut ontomain.SM_CONVERTIBLESLATEMODE(non-convertible desktops report slate/0). Open to a different signal (e.g.UserInteractionMode/touch-initiated focus) if preferred.