Repository navigation
fix: prevent Tab key from inserting character in TextBox on Skia - #22823
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency in Skia TextBox keyboard handling where pressing Tab could insert a \t character into the text on some backends, instead of only performing focus navigation (WinUI-compatible behavior).
Changes:
- Update Skia
TextBoxkey handling to explicitly ignore Tab for text insertion while allowing it to bubble for focus navigation. - Add a Skia runtime test to validate that a Tab keydown carrying unicode
'\t'does not modifyTextBox.Text.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs |
Adds an explicit VirtualKey.Tab case to prevent '\t' insertion while still allowing focus navigation handling upstream. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs |
Adds a runtime regression test ensuring Tab (with unicode '\t') does not insert text in Skia TextBox. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22823/wasm-skia-net9/index.html |
|
The build 201159 found UI Test snapshots differences: Details
|
|
|
|
I don't see this on SamplesApp inside any textbox. Tab will just move focus. Is there a specific scenario that needs this? |
@ramezgerges are you on mac? I believe this is specific to macOS. I was able to reproduce it, but on mac. |
|
@ramezgerges yes, it is only happening on some targets, Win32 for example already prevented it above in the native layer I think |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The build 202708 found UI Test snapshots differences: Details
|
|
The build 202708 found UI Test snapshots differences: Details
|
|
|
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days. |
3bb40bc to
7e6dae8
Compare
|
Claude finished @MartinZikmund's task in 2m 32s —— View job Review complete
The fix is correct in intent: using 3 findings — 1 medium, 2 low:
The focus assertion added in the latest commit ( |
d6af3ae to
1b87c3d
Compare
|
Claude finished @MartinZikmund's task in 4m 56s —— View job Review complete
Verdict: ship ✅ What changed in this sync (vs. the previously reviewed round): The fix has been relocated from
One low-severity finding posted as an inline comment: the comment on |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22823/wasm-skia-net9/index.html |
|
The build 229525 found UI Test snapshots differences: Details
|
|
|
1b87c3d to
215533e
Compare
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22823/wasm-skia-net9/index.html |
|
The build 230965 found UI Test snapshots differences: Details
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22823/wasm-skia-net9/index.html |
|
The build 231730 found UI Test snapshots differences: Details
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Code review assessment of the current head: returning for Tab prevents insertion of the backend-supplied control character without marking the key handled, leaving routed focus navigation available. The separate character-release path already rejects control characters. This is consistent with TextBox/PasswordBox not exposing AcceptsTab; it does not prevent programmatic/pasted text containing tabs. No blocking issue found in the insertion fix. Ending the typing transaction when Tab cannot transfer focus is a useful non-blocking undo-boundary follow-up. This reviews the updated head rather than merely repeating the old approval.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
215533e to
4f57a43
Compare
|
Claude finished @MartinZikmund's task in 2m 52s —— View job Review complete
Verdict: ship ✅ — no new inline findings I re-reviewed the current head (
One pre-existing low-severity nit, not re-flagged inline: the comment on Cross-cutting, non-blocking: the CI snapshot-diff comments on this PR (e.g. build 231730) list hundreds of unrelated screenshots ( |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22823/wasm-skia-net9/index.html |
|
The build 237240 found UI Test snapshots differences: Details
|
…box-6.8 fix: prevent Tab key from inserting character in TextBox on Skia (backport #22823) (6.8)
…box-6.7 fix: prevent Tab key from inserting character in TextBox on Skia (backport #22823) (6.7)
…kport unoplatform#22823) Manual backport of unoplatform#22823 to servicing/6.8. In 7.0 this switch lives in TextBoxCore.Input.cs; on 6.x it is the same switch in TextBox.skia.cs, so the four lines and the runtime test are applied there by hand (Mergify can't follow the file move). Related to unoplatform#22818 Co-authored-by: Martin Zikmund <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…kport unoplatform#22823) Manual backport of unoplatform#22823 to release/stable/6.7. In 7.0 this switch lives in TextBoxCore.Input.cs; on 6.x it is the same switch in TextBox.skia.cs, so the four lines and the runtime test are applied there by hand (Mergify can't follow the file move). Related to unoplatform#22818 Co-authored-by: Martin Zikmund <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Fixes #22818
On several Skia backends (macOS, FrameBuffer/Linux, Android), pressing Tab in a
TextBoxinserts a\tcharacter into the text in addition to moving focus. The expected WinUI behavior is that Tab should only move focus and never insert a character —TextBoxhas noAcceptsTabproperty (onlyRichEditBoxdoes).Root cause
In
TextBox.OnKeyDownSkia(), there was no explicitcase VirtualKey.Tab:in the second switch statement (text input/movement). When a backend passes the tab unicode character (0x09) throughKeyRoutedEventArgs.UnicodeKey, the unhandled key fell into thedefaultcase which inserts any non-nullUnicodeKeyas text. Focus navigation happens later inUnoFocusInputHandler(on the root element's KeyDown), but by then the tab character was already inserted.Affected backends: macOS, FrameBuffer (Linux), Android — all pass unicode
0x09for Tab.Unaffected backends: Win32, WPF, X11, and WebAssembly already filter it out at the platform layer.
WinUI comparison
WinUI blocks Tab insertion through multiple layers:
WM_CHARfor Tab, so no character input event existsKeyboardInputProcessortriggersUIElement_TabProcessingfor focus navigation beforeCharacterReceivedfiresIn Uno/Skia, layer 1 is inconsistent across backends, layer 2 (
UnoFocusInputHandler) runs after TextBox processes the key, and there's no RichEdit layer. This fix mirrors WinUI's intent by preventing Tab from reaching character insertion.Fix
Added
case VirtualKey.Tab:with areturn;before thedefaultcase inTextBox.skia.cs:Handled— we usereturn(notbreak), so the event bubbles upUnoFocusInputHandler.OnKeyDown()handles Tab for focus navigation as beforeUsing
return(notbreak) is important becausebreakwould fall through toProcessTextInput(text), whereasreturnexits the method immediately.Changes
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs— Addcase VirtualKey.Tab: return;before the default casesrc/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs— Add runtime testWhen_Tab_Pressed_Should_Not_Insert_CharacterTest plan
Uno.UI.Skia.csprojandUno.UI.RuntimeTests.Skia.csprojbuild with 0 errorsWhen_Tab_Pressed_Should_Not_Insert_Character— creates a TextBox, simulates Tab with unicode\t, asserts no tab character is inserted\tcharacter appears and focus moves to the next control🤖 Generated with Claude Code