Skip to content

fix: prevent Tab key from inserting character in TextBox on Skia (backport #22823) (6.7) - #25783

Merged
agneszitte merged 1 commit into
release/stable/6.7from
dev/agzi/bp-22823-tab-textbox-6.7
Oct 28, 2026
Merged

agneszitte merged 1 commit into
release/stable/6.7from
dev/agzi/bp-22823-tab-textbox-6.7

Conversation

@agneszitte

Copy link
Copy Markdown
Member

GitHub Issue: Related to #22818

Backport of #22823 to release/stable/6.7.

PR Type:

🐞 Bugfix

What changed? 🚀

On Skia (macOS, Linux framebuffer, Android), pressing Tab in a TextBox inserted a tab character as well as moving focus. WinUI's TextBox never inserts a tab (it has no AcceptsTab). The key-down switch now returns early on VirtualKey.Tab, so focus navigation still happens and no character is inserted.

In 7.0 this switch lives in TextBoxCore.Input.cs; on 6.x it is the same switch in TextBox.skia.cs, so this is a manual port (Mergify can't follow the file move). The runtime test When_Tab_Pressed_Should_Not_Insert_Character is the one from the master PR, unchanged.

PR Checklist ✅

  • 🧪 Runtime test included (from the master PR)
  • ❗ Contains NO breaking changes

🤖 Generated with Claude Code

…kport #22823)

Manual backport of #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 #22818

Co-authored-by: Martin Zikmund <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @agneszitte's task in 2m 18s —— View job


Code Review

  • Gather context and read changed files
  • Review TextBox.skia.cs changes
  • Review Given_TextBox.skia.cs test changes
  • Post inline review comments
  • Post summary

Summary

Verdict: LGTM — no blocking issues.

The fix is minimal, correctly scoped, and matches WinUI semantics. One informational note posted inline (see below).

TextBox.skia.cs — the fix

Adding case VirtualKey.Tab: return; in the second switch of OnKeyDownSkia (the "text input/movement" switch) is the right insertion point. Without it, the default: arm picks up the unicodeKey: '\t' delivered by macOS/FrameBuffer/Android backends and inserts it via ProcessTextInput. The early return (without setting args.Handled) is also correct: it lets the event propagate so UnoFocusInputHandler can drive Tab-focus navigation, matching WinUI semantics where TextBox has no AcceptsTab. The two-line comment earns its place — it explains the non-obvious interaction with the focus handler.

OnKeyDownPartial (the pre-processing pass that pre-marks events as Handled) does not need a matching VirtualKey.Tab case; Tab is intentionally left unmarked so the focus manager can consume it.

Given_TextBox.skia.cs — the test

The test structure is correct: TextBoxFeatureConfigDisposable ensures config cleanup even on exception; WindowHelper.WindowContent = panel is correctly followed by WaitForIdle + WaitForLoaded(SUT); the method is async Task as required by the await calls. Both assertions cover the two sides of the correct behavior (no char insertion, and focus navigation).

One note (posted as an inline comment): the focus-navigation assertion (Assert.AreEqual(button, focusedElement)) is contingent on SafeRaiseEvent(UIElement.KeyDownEvent, ...) actually wiring into the focus pipeline on Skia 6.7. Since the test was ported unchanged from the master PR, please confirm it produces a green result on CI for this branch before merging — any pipeline wiring difference between 6.7 and 7.0 would cause it to fail or to become a no-op assertion.

@agneszitte
agneszitte merged commit 8a15049 into release/stable/6.7 Oct 28, 2026
10 of 12 checks passed
@agneszitte
agneszitte deleted the dev/agzi/bp-22823-tab-textbox-6.7 branch October 28, 2026 03:08

Assert.AreEqual(string.Empty, SUT.Text, "Tab should not insert a character in TextBox");

// Ensure that Tab key still moves focus to the next control

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.

The focus-navigation assertion (Assert.AreEqual(button, focusedElement, ...)) depends on SafeRaiseEvent(UIElement.KeyDownEvent, ...) actually flowing through the focus pipeline (e.g. UnoFocusInputHandler). If that pipeline is not wired into routed-event dispatch on Skia, focus stays on SUT and this assertion would fail deterministically — which would have surfaced in CI on the master PR, so it is probably fine. That said, it is worth confirming with a passing CI run on the backport branch before merge, since any wiring differences between 6.7 and 7.0 could break this assertion silently (making it always fail, or never test what it says it tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant