Skip to content

fix(wasm-a11y): Allow disabling accessibility again - #24636

Merged
MartinZikmund merged 2 commits into
masterfrom
dev/mazi/wasm-a11y-disable
Sep 25, 2026
Merged

MartinZikmund merged 2 commits into
masterfrom
dev/mazi/wasm-a11y-disable

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24635

PR Type:

🐞 Bugfix

What changed? 🚀

Skia WebAssembly accessibility could only be turned on. Once a Given_Accessible* / Given_WasmAria* test enabled it, it stayed on for every later test in that WASM app. That made those tests slower (the semantic DOM follows every visual, focus and scroll change) and changed focus behavior: focusing a TextBox bounced Focused → Normal → Focused, which is what made the editable-ComboBox dark-theme tests flaky in WASM shard 1 (see #24600 / #24601).

Product (Uno.UI.Runtime.Skia.WebAssembly.Browser)

  • New WebAssemblyAccessibility.DisableAccessibility() (JS-exported, internal type), the counterpart of EnableAccessibility(). It unhooks FocusDeparting, focus sync, the IsFocusable callback and live regions, restores native focus, deactivates modal focus traps, disposes the virtualized/ComboBox regions, clears the semantic maps and pending updates, then clears the semantic DOM, focus sentinels and live-region elements and brings the "Enable accessibility" button back.
  • The ItemsRepeater, ListView and ContentDialog handlers were anonymous lambdas that were never unsubscribed. They're now detachable (a region detaches on dispose; dialogs are tracked weakly), so re-enabling doesn't subscribe them twice. This also stops a repeater/ListView leaving the tree from keeping its handlers.
  • Accessibility.disableAccessibility() exposes it to JS for the runtime tests.

Tests

  • Every accessibility test class now calls WasmSemanticDomHelper.DisableAccessibility() in its [TestCleanup]. The helper does nothing outside the browser.
  • New Given_WasmAccessibilityLifecycle: the semantic DOM is removed on disable, a TextBox focus no longer bounces after disabling, and re-enabling rebuilds the tree without duplicating live regions or sentinels.

Validation

All runs on Skia WebAssembly (headless Chrome, net11.0-browserwasm, Release):

Scenario Before (tests only) After
Given_WasmAccessibilityLifecycle (3 tests) 🔴 3/3 fail, no way to disable 🟢 3/3 pass
Given_AccessibleTextBox, then the two editable-ComboBox dark-theme tests (master's binding code, without #24601) 🔴 both ComboBox tests fail (dark text) 🟢 both pass
Whole Windows_UI_Xaml_Automation namespace + the ComboBox pair n/a 🟢 262 passed, 22 skipped, 0 failed

So this fixes the CI flake on its own, independently of #24601, which fixes the underlying setter bug.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01Da9FjW3KpXk99Zo4YyViTE

MartinZikmund and others added 2 commits September 24, 2026 15:11
EnableAccessibility had no counterpart, so the semantic DOM, focus sync,
native-focus suppression and live regions stayed on for the rest of the
app. DisableAccessibility tears all of it down and brings the enable
button back, so it can be turned on again.

The ItemsRepeater, ListView and ContentDialog handlers are now detachable
so a re-enable does not subscribe them twice.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Da9FjW3KpXk99Zo4YyViTE
The accessibility tests left it on for every later test in the WASM app,
slowing them down and making a TextBox focus bounce through the semantic
DOM. Each a11y test class now disables it in its cleanup, and new tests
cover disabling and re-enabling.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Da9FjW3KpXk99Zo4YyViTE
@MartinZikmund MartinZikmund self-assigned this Sep 24, 2026
@github-actions github-actions Bot added the platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform label Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 53s —— View job


Review complete ✅

Todo list

  • Gather context (diff, changed files, AGENTS.md rules)
  • Review product code (WebAssemblyAccessibility.cs, FocusSynchronizer.cs, VirtualizedSemanticRegion.cs)
  • Review TypeScript changes (Accessibility.ts, LiveRegion.ts, SemanticElements.ts)
  • Review test changes (Given_WasmAccessibilityLifecycle.cs, WasmSemanticDomHelper.cs, other test classes)
  • Post inline findings (none warranted — see below)
  • Post summary comment

Verdict: ship — no inline findings were posted; nothing rose to a level that blocks merge.

What I verified:

  • DisableAccessibility() is the correct mirror of EnableAccessibility(): every subsystem it starts (FocusSynchronizer.Initialize, LiveRegionManager, Control.OnIsFocusableChangedCallback, FocusManager.SuppressNativeFocus, the FocusController.FocusDeparting subscription, focus sentinels, modal scopes, virtualized regions, combo-box tracking) has a matching teardown step, and all mutable state (_semanticParentMap, _prunedHandles, _pendingLabelledBy, _relationshipPeers, _rootElementHandle, _focusSearchRoot, etc.) is reset — this is a root-cause fix, not a guard-only patch.
  • The ItemsRepeater/ListView handlers were converted from anonymous lambdas to named local functions with a region.Detach callback wired to VirtualizedSemanticRegion.Dispose() — confirmed each region is only ever bound to one container (ItemsRepeater or ListView), so Detach is never overwritten.
  • ContentDialog tracking via ConditionalWeakTable<ContentDialog, Action> correctly guards TryRegisterModalDialog against re-subscribing an already-tracked dialog, and DisableAccessibility unsubscribes + clears the table so a subsequent EnableAccessibility() re-walk re-registers cleanly.
  • TS side (resetSemanticsRoot, LiveRegion.teardown, SemanticElements.resetVirtualizedMutations) tears down DOM nodes/RAF callbacks and restores the "Enable accessibility" button without duplicating it, guarded by isEnableAccessibilityButtonActive().
  • LiveRegionManager.ClearPending() disposes both debounce timers before nulling the manager, so no stale Timer callback can fire after teardown.
  • Test coverage matches the red→fix→green protocol: Given_WasmAccessibilityLifecycle covers DOM removal, the TextBox focus-bounce regression, and re-enable-without-duplication. The mechanical [TestCleanup] DisableAccessibilityAfterTest() addition across the ten Given_Accessible*/Given_WasmAria* classes is guarded by OperatingSystem.IsBrowser() inside the helper, so it's a safe no-op on non-browser runs; confirmed no file ends up with more than one [TestCleanup] method (which would throw at MSTest runtime).
  • No new event Action/Action<T> public surface was introduced — VirtualizedSemanticRegion.Detach is an internal cleanup-callback field, not a public event contract.
  • Changes are correctly scoped to Uno.UI.Runtime.Skia.WebAssembly.Browser (WASM-specific runtime project); no platform code leaked into shared files.

Minor, non-blocking observation: the #if HAS_UNO [TestCleanup] public void DisableAccessibilityAfterTest() => DisableAccessibility(); #endif block is duplicated verbatim across 10 test classes. A shared base class could remove the duplication, but it matches this test suite's existing per-class-helper convention, so I didn't file it as a finding.

@unodevops

Copy link
Copy Markdown
Contributor

@morning4coffe-dev morning4coffe-dev 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.

LGTM! Allowing accessibility to be cleanly disabled between tests prevents semantic DOM pollution across WASM shards.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235500 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ImageIconPage.png-dark
    • Image_AnimatedWebP.png-dark
  • skia-windows-screenshots: 2310 changed over 2498

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AndroidWindowInsets.png
    • AndroidWindowInsets.png-dark
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewMode.png-dark
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppWindowFeatures.png-dark
    • ApplicationViewSizing.png-dark
    • AppXamlDefinedResources.png-dark
    • AppWindowTitleBar Properties.png
    • AppWindowPositionAndSize.png-dark
    • Attributed_text_Simple.png
    • Attributed_text_Simple.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutomationProperties_AutomationId.png-dark
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@MartinZikmund
MartinZikmund merged commit 31cdb24 into master Sep 25, 2026
55 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/wasm-a11y-disable branch September 25, 2026 05:04
@ramezgerges ramezgerges mentioned this pull request Oct 27, 2026
2 of 5 tasks
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] Allow disabling accessibility again after it was enabled

4 participants