Skip to content

fix(a11y): Stop TextBox focus bouncing with WASM accessibility on - #26241

Open
morning4coffe-dev wants to merge 8 commits into
masterfrom
dev/doti/wasm-tree-textbox-focus
Open

morning4coffe-dev wants to merge 8 commits into
masterfrom
dev/doti/wasm-tree-textbox-focus

Conversation

@morning4coffe-dev

Copy link
Copy Markdown
Member

GitHub Issue: closes #24866

PR Type:

🐞 Bugfix

What changed? 🚀

With WASM accessibility enabled, focusing a TextBox raised GotFocus, LostFocus, then GotFocus again. Two inputs were fighting over browser focus:

  1. StartEntry focused the hidden native <input> used for typing.
  2. The semantic focus sync then moved browser focus to the TextBox's semantic element, which blurred the hidden input. That blur was reported as user-initiated (OnNativeBlur → Unfocus).
  3. The semantic element's focus then echoed back as a new Focus(Keyboard), which also overwrote the original FocusState.

Changes:

  • BrowserInvisibleTextBoxViewExtension.ts focus(): when the control has a semantic node, that node is focused directly (with the blur handler suppressed) and the hidden input isn't used. The semantic input is already a real, editable <input>, so this leaves one element holding browser focus.
  • FocusSynchronizer.OnBrowserFocus: a browser focus on the semantic node of the element that already has XAML focus is an echo and is ignored, so FocusState is no longer overwritten with Keyboard.

Tests: Given_WasmAccessibleTextBoxFocus checks a TextBox focused programmatically, by keyboard and by pointer, plus a PasswordBox and a browser-initiated focus on the semantic input. Each gets exactly one GotFocus, no LostFocus, and the right FocusState.

Also checked by hand with real Tab, a mouse click and a screen-reader style .focus(): one GotFocus each, and typed text arrives. I didn't test on a real mobile device or with an IME. Master changed the same TS file recently for the soft keyboard and IME fixes; this rebases cleanly onto them, but a quick check on a phone would be good.

PR Checklist ✅

🤖 Generated with Claude Code

@morning4coffe-dev morning4coffe-dev self-assigned this Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 19s —— View job


Review summary

Verdict: looks good, with minor follow-ups. This is a root-cause fix. It removes the competing focus of the hidden input and the semantic node, and it ignores the echo, rather than adding a guard. The runtime tests cover the scenarios in the description (programmatic, keyboard and pointer focus, PasswordBox, and a browser-initiated focus on the semantic input).

Issues: 0 high, 1 medium, 1 low (inline).

  • Medium: the echo early-return in OnBrowserFocus skips the roving-tabindex and focus-tracking updates.
  • Low: the test relies on a fixed Task.Delay(300) for its negative assertions.

Cross-cutting notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests here, so there is no Compile or Runtime evidence from me.
  • The soft-keyboard and IME paths in the TS file are untested on a real device, as the description says. A mobile check is still worth doing before merge.
  • The code style, the conventional-commit title and the linked issue all look fine.

@github-actions github-actions Bot added the platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform label Nov 9, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 12s —— View job


Review summary

Verdict: looks good. Since the previous review, the echo path in OnBrowserFocus has changed. It now skips only control.Focus(FocusState.Keyboard). UpdateRovingTabindex and TrackFocusedElement still run, and _previousFocusedHandle is only updated when the handle actually changes. That addresses the earlier medium finding. A new test, When_Focused_Radio_Gets_Browser_Focus_Then_Roving_Tab_Stop_Follows, covers the composite-child case.

Issues: 0 high, 0 medium, 1 low (still open).

  • Low: SettleAsync still ends with a fixed Task.Delay(300) for the negative assertions (no LostFocus, no second GotFocus). That can pass on a slow runner before a bounce arrives. The earlier inline comment on this still applies. If you keep the delay, add a comment saying why 300 ms is enough, or wait on a deterministic signal such as a requestAnimationFrame round-trip.

Notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests, so there is no Compile or Runtime evidence from me.
  • The soft-keyboard and IME paths in the TS file are untested on a real device, as the description says. A quick phone check before merge is still worthwhile.
  • Code style, the conventional-commit title and the linked issue look fine.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 244702 found UI Test snapshots differences: skia-linux-screenshots: 240, skia-windows-screenshots: 305

Details
  • skia-linux-screenshots: 240 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AnimatedVisualsTestbedPage.png
    • AutomationProperties_StructureAndProps.png-dark
    • BasicAcrylicBrushTest2.png-dark
    • AutomationProperties_AutomationId.png
    • BasicAcrylicBrushTest2.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest.png-dark
    • Basics.png-dark
    • BasicAcrylicBrushTest.png
    • Basics.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
  • skia-windows-screenshots: 305 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AnimatedVisualsTestbedPage.png-dark
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • AnimatedBackVisualSourceSamplePage.png
    • AutomationProperties_StructureAndProps.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_AutomationId.png

@morning4coffe-dev
morning4coffe-dev force-pushed the dev/doti/wasm-tree-textbox-focus branch from 479416b to a16d8cc Compare November 9, 2026 21:26
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 11s —— View job


Review summary

Verdict: looks good. I found nothing new to block on.

Issues: 0 high, 0 medium, 0 low.

  • The fix is a root-cause fix. focus() in the TS file now focuses the semantic node directly with the blur handler suppressed (runSuppressingBlur exists and is used the same way elsewhere in the file). OnBrowserFocus treats focus on the already-focused element as an echo.
  • The echo path skips only control.Focus(FocusState.Keyboard). Roving tabindex and focus tracking still run, and _previousFocusedHandle is only updated when the handle changes. That addresses the earlier medium finding.
  • The Task.Delay(300) now has a comment explaining why it is there, which resolves the earlier low finding.

Notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests, so there is no Compile or Runtime evidence from me.
  • The soft-keyboard and IME paths in the TS file are untested on a real device, as the description says. A quick phone check before merge is still worthwhile.
  • The CI report shows many screenshot differences on the Skia Linux and Windows jobs. The PR only touches the WASM browser runtime and a WASM-only runtime test, so these look unrelated. Please confirm that on the screenshot comparison run.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 244955 found UI Test snapshots differences: skia-linux-screenshots: 240, skia-windows-screenshots: 291

Details
  • skia-linux-screenshots: 240 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • AppWindowTitleBar Properties.png-dark
    • Basics.png-dark
    • Basics.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
  • skia-windows-screenshots: 291 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedVisualsTestbedPage.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 12s —— View job


Review summary

Verdict: looks good. I found nothing new to block on. The new commits since the last review are test-only (a16d8ccd, 77f02dd1). The production diff in FocusSynchronizer.cs and BrowserInvisibleTextBoxViewExtension.ts is unchanged.

Issues: 0 high, 0 medium, 0 low.

  • The fix addresses the root cause. Only one element now holds browser focus, and the echo no longer overwrites FocusState.
  • The echo path still updates the roving tab stop and focus tracking, and it skips only Focus(Keyboard).
  • _previousFocusedHandle is updated only when the handle changes.
  • focus() in the TS file focuses the semantic node with the blur handler suppressed, then calls detach() and returns false. That matches the previous "already focused" branch.

Notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests, so there is no Compile or Runtime evidence from me.
  • If the semantic node can ever be a non-editable element (for example a div), typing would silently stop working. The PR says it is always a real <input> for text controls. I didn't re-verify that.
  • The soft-keyboard and IME paths are untested on a real device, as the description says. A quick phone check is still worthwhile.
  • The Skia Linux and Windows screenshot differences (240 and 291) are almost the same set of samples in both runs. The PR touches only the WASM browser runtime and a WASM-only test, so they look unrelated. Please confirm on the comparison run.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 245166 found UI Test snapshots differences: skia-linux-screenshots: 259, skia-windows-screenshots: 300

Details
  • skia-linux-screenshots: 259 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedVisualsTestbedPage.png-dark
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppWindowTitleBar Properties.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • Basics.png-dark
    • Basics.png
  • skia-windows-screenshots: 300 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • AutomationProperties_StructureAndProps.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • Basics.png-dark
    • Basics.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png

@mergify

mergify Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

@MartinZikmund MartinZikmund left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morning4coffe-dev The fix looks right to me. It removes the actual cause (two inputs fighting over DOM focus) instead of muting OnNativeBlur, and dropping the echo matches WinUI: CFocusManager::UpdateFocus (dxaml/xcp/core/dll/focusmgr.cpp, the pNewFocus == m_pFocusedElement branch) re-raises GotFocus and rewrites FocusState when Focus() hits the already-focused element with a different state. So an echo that isn't a real focus request has to stop before Focus(). I also checked that FocusManager.mux.cs assigns _focusedElement before UpdateFocusState -> StartEntry, so the synchronous echo from semanticElement.focus() is detected correctly.

One thing before I approve:

  • The TextBox/PasswordBox tests most likely can't fail on CI (details inline). Please add an assertion that doesn't depend on browser focus events.

Optional nit inline on the echo check.

Chrome holds focus and blur events back while its window lacks OS focus, as on the CI agents, so the GotFocus log alone could pass without the fix. Assert the shared hidden input is never attached, which the bouncing path does regardless of event delivery.
An element without a semantic node of its own mirrors its focus onto its nearest semantic ancestor. A deferred browser focus event for that ancestor was re-applied as Keyboard focus on the ancestor, pulling XAML focus off the element.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 18s —— View job


Review summary

Verdict: looks good. I found nothing new to block on.

Issues: 0 high, 0 medium, 0 low.

  • The two latest commits (384833af, e55d924b) address the open review points from MartinZikmund.
    • The tests now watch the shared #uno-input with a MutationObserver (StartWatchingSharedInput / StopWatchingSharedInput). That assertion doesn't depend on browser focus events, so it can fail on CI without the TS fix.
    • The echo check in OnBrowserFocus now also covers a focused element that has no semantic node of its own, via _accessibility.ResolveToSemanticHandle(focused) == handle. That was the optional nit.
  • The production fix is unchanged in intent. The echo skips only Focus(Keyboard), and roving tabindex and focus tracking still run.

Notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests, so there is no Compile or Runtime evidence from me.
  • Martin asked for confirmation that the new #uno-input assertion fails with the TS change reverted. I couldn't verify that, so please run it and report the result in the PR.
  • The soft-keyboard and IME paths are still untested on a real device, as the description says. A quick phone check is worthwhile.
  • The Skia Linux and Windows screenshot differences look unrelated. The PR touches only the WASM browser runtime and a WASM-only test, but please confirm on the comparison run.
    · Branch: dev/doti/wasm-tree-textbox-focus

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248150 found UI Test snapshots differences: skia-linux-screenshots: 280, skia-windows-screenshots: 255

Details
  • skia-linux-screenshots: 280 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_AutomationId.png
    • Basics.png-dark
    • Basics.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest.png-dark
  • skia-windows-screenshots: 255 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_Showcase.png-dark
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppWindowTitleBar Properties.png-dark
    • AppWindowTitleBar Properties.png
    • AnimatedVisualsTestbedPage.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AnimatedVisualsTestbedPage.png-dark
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png

…textbox-focus

# Conflicts:
#	src/Uno.UI.Runtime.WebAssembly.Browser/Accessibility/FocusSynchronizer.cs
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 17s —— View job


Review summary

Verdict: looks good. I found nothing new to block on.

Issues: 0 high, 0 medium, 0 low.

  • The production diff is unchanged in intent since the last review. focus() in the TS file still focuses the semantic node directly with the blur handler suppressed. OnBrowserFocus still skips only Focus(Keyboard) on an echo. Roving tabindex and focus tracking still run.
  • _previousFocusedHandle is now updated only when the handle changes, so a repeated echo no longer overwrites it.
  • The echo check now also matches ResolveToSemanticHandle(focused) == handle. That was Martin's optional nit.

Notes

  • I reviewed by inspection only. I did not build or run the WASM runtime tests, so there is no Compile or Runtime evidence from me.
  • The author reports a local run on headless Edge with the TS change reverted. The bounce tests then fail on the #uno-input MutationObserver assertion, and they pass with the fix restored. I couldn't confirm this myself.
  • Edge case in the widened echo check: suppose a focused element has no semantic node of its own, and a user or screen reader moves browser focus to its semantic ancestor. That is now ignored, so the DOM and XAML focus stay on different elements. This is unlikely and is the trade-off for covering the late-echo case. A short comment on it would help, but it isn't blocking.
  • The soft-keyboard and IME paths are untested on a real device, as the description says. A quick phone check is worthwhile.
  • The Skia Linux and Windows screenshot differences (280 and 255) look unrelated. The PR touches only the WASM browser runtime and a WASM-only test, but please confirm on the comparison run.
    · Branch: dev/doti/wasm-tree-textbox-focus

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248213 found UI Test snapshots differences: skia-linux-screenshots: 217, skia-windows-screenshots: 239

Details
  • skia-linux-screenshots: 217 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • AutomationProperties_AutomationId.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CornerRadiusControls.png-dark
    • CornerRadiusControls.png
    • Accessibility_Showcase.png
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • Basics.png-dark
    • BenchmarkDotNet.png-dark
    • Basics.png
    • BenchmarkDotNet.png
    • Buttons.png-dark
    • BreadcrumbBarPage.png-dark
  • skia-windows-screenshots: 239 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AnimatedBackVisualSourceSamplePage.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • AppWindowTitleBar Properties.png
    • AppWindowTitleBar Properties.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationPropertiesExtensions_Role.png-dark
    • AutomationPropertiesExtensions_Role.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • Accessibility_Showcase.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark

@morning4coffe-dev

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

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

Labels

platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM][A11y] Focusing a TextBox blurs and refocuses it when accessibility is enabled

4 participants