Skip to content

fix(a11y): Don't scroll when mirroring focus to the DOM - #24605

Merged
MartinZikmund merged 3 commits into
masterfrom
dev/mazi/flaky-wasm-gotfocus
Oct 9, 2026
Merged

MartinZikmund merged 3 commits into
masterfrom
dev/mazi/flaky-wasm-gotfocus

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24604

PR Type:

🐞 Bugfix

What changed? 🚀

With accessibility enabled on WebAssembly, Accessibility.focusSemanticElement mirrored XAML focus into the semantic DOM with a plain element.focus(). The browser then scrolled the ScrollContentPresenter's semantic <div overflow:scroll> to reveal the focused node, and the scroll listener fed that offset back into the XAML ScrollViewer (OnScroll → ScrollContentPresenter.Set, animated). Programmatic focus in WinUI never scrolls.

Both focus() calls in focusSemanticElement now pass { preventScroll: true }, the same as the text-input extension. XAML stays the owner of scrolling. This path only mirrors focus that XAML already moved, and XAML does its own bring-into-view where WinUI does.

This is the cause of the WASM flake Given_TextBox.When_GotFocus_BringIntoView (5 of the last 30 master builds, Expected:<0>. Actual:<N> with N varying 40-457 because the scroll is caught mid-animation). It only fires in shards where earlier Given_Accessible* tests left accessibility on. It is a separate mechanism from #24597 (scroll echoes), and both are needed: #24597 stops our own pushes from being echoed back, and this stops the browser from starting a scroll of its own.

Validation

  • Runtime, local headless Chrome, net11.0-browserwasm Release:
    • The new Given_AccessibleScrollViewer.When_Programmatic_Focus_Outside_Viewport_Then_Not_Scrolled fails without the fix (semantic scrollTop 1877 instead of 0) and passes with it.
    • The other Given_AccessibleScrollViewer tests and When_GotFocus_BringIntoView pass.
  • Runtime, diagnostic (not committed):
    • Without the fix, the semantic scroller reached scrollTop=426 within 3 ms of Focus(), and VerticalOffset then animated 0 → 11 → 65 → 81 through OnScroll.
    • With the fix, the offset stays at 0 for 500 ms.
  • Merging after fix(a11y): Don't feed semantic scroll echoes back to ScrollViewer #24597 gives a trivial conflict in Given_AccessibleScrollViewer.cs (each adds a test at the same spot).

Not covered: keyboard navigation inside the semantic DOM (SemanticElements.ts, FocusTrap.ts) also uses plain .focus(). That was found by code review only.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm

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

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 18s —— View job


Review complete ✅

Verdict: ship. No inline findings posted — this is a minimal, well-targeted fix with no correctness, style, or convention issues found.

What I checked:

  • The two-line diff (element.focus({ preventScroll: true }) in both the immediate and requestAnimationFrame-retried paths of focusSemanticElement) is the right fix for the described mechanism: browser-initiated scroll-into-view on programmatic focus feeding back through the scroll listener into ScrollContentPresenter. This mirrors the existing preventScroll usage in BrowserInvisibleTextBoxViewExtension.ts.
  • The new test When_Programmatic_Focus_Outside_Viewport_Then_Not_Scrolled follows repo runtime-test conventions ([RunsOnUIThread], PlatformCondition(Include, SkiaWasm), uses the shared WasmSemanticDomHelper), asserts against both the DOM (scrollTop walk up the ancestor chain) and the XAML side (scrollViewer.VerticalOffset), and per the PR description was verified red-before/green-after against the actual bug — satisfying the repo's root-cause-first validation protocol.
  • Code style (tabs, comment brevity/placement, no braces omitted) is consistent with .claude/rules/code-style.md.
  • Commit messages follow Conventional Commits (fix(a11y): ..., test(a11y): ...).

Non-blocking observations (not filed as inline comments since they're outside this PR's disclosed scope):

  • The PR description already flags that SemanticElements.ts (arrow-key nav in tree/menu widgets, FocusTrap.ts) still call plain .focus() without preventScroll. I confirmed several such call sites exist. Since this was found and disclosed by the author via code review and is arguably a separate concern (keyboard nav arguably should bring the item into view, unlike this programmatic-mirroring path), it seems reasonable to leave as a tracked follow-up rather than in-scope here.
  • Minor style nit: Given_AccessibleScrollViewer.cs has 3 blank lines before the closing #endif (lines 191–194) — harmless, but could be trimmed to match the rest of the file's spacing.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235263 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) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Buttons.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
  • skia-windows-screenshots: 2310 changed over 2442

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBarToggleButtonTest.png
    • AppWindowFeatures.png
    • AppXamlDefinedResources.png
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithtopmargin.png
    • AutoSizedTopLeft.png-dark
    • AutoSuggestBox_Keyboard.png-dark
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Generic.png
    • BorderCenteredwithmargins.png-dark
    • BorderCenteredwithmargins.png
    • BorderRightwithmargins.png-dark
    • BorderRightwithmargins.png
    • BorderWithNullBrushAndNonZeroThickness.png-dark
    • BorderWithNullBrushAndNonZeroThickness.png
  • wasm: 11 changed over 1076

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

@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! Using preventScroll: true correctly stops programmatic focus mirroring from scrolling the semantic container.

@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 force-pushed the dev/mazi/flaky-wasm-gotfocus branch from 31214a8 to e1296ff Compare September 25, 2026 22:21
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete ✅

Verdict: ship. No commits have changed since the prior automated review on this PR — I independently re-verified the diff against AGENTS.md and found no correctness, contract, or style issues. No inline comments filed.

What I verified:

  • focusSemanticElement's two .focus() call sites (immediate + requestAnimationFrame retry) both now pass { preventScroll: true }, matching the existing pattern in BrowserInvisibleTextBoxViewExtension.ts. This is the single interop entry point used by all native-focus call sites (FocusManager.cs, FocusSynchronizer.cs, WebAssemblyAccessibility.cs), so the fix applies uniformly without duplication.
  • The new test When_Programmatic_Focus_Outside_Viewport_Then_Not_Scrolled correctly sits inside the file's existing #if HAS_UNO region (closed by the single trailing #endif), uses existing WasmSemanticDomHelper helpers with matching signatures (EnsureAccessibilityEnabledAsync, SemanticElementExists, GetSemanticElementId, InvokeBrowserJs), follows repo conventions ([RunsOnUIThread], PlatformCondition(Include, SkiaWasm), tabs, braces), and asserts both the DOM-level signal (scrollTop walked up the ancestor chain, read immediately after Focus(), matching the synchronous JSImport call path in FocusManager.FocusNative) and the XAML-level signal (ScrollViewer.VerticalOffset).
  • Per the PR description, the test was verified red-before/green-after against the real bug, satisfying the repo's root-cause-first validation protocol — this is a root-cause fix (removing the browser-initiated scroll trigger), not a guard.
  • Commit messages follow Conventional Commits.

Non-blocking, out of scope for this PR:

  • Same file, Accessibility.ts:404 (sentinel.focus() in the focus-trap departure sentinel) is a plain .focus() call not covered by this fix — but the sentinel is position: fixed; top:0; left:0, effectively always in-viewport, so it's unlikely to trigger a scroll in practice.
  • The PR body already discloses further plain .focus() call sites in SemanticElements.ts (arrow-key nav) and FocusTrap.ts as follow-up candidates; reasonable to leave as tracked follow-up since keyboard navigation arguably should bring the item into view (unlike this focus-mirroring path).
  • Minor style nit (previously noted): a few extra blank lines before the closing #endif in Given_AccessibleScrollViewer.cs.
    · Branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235798 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) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
  • skia-windows-screenshots: 2310 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png-dark
    • AppBarButtonTest.png
    • AppBarToggleButtonTest.png
    • AppBar_KeyBoard.png-dark
    • AppBar_KeyBoard.png
    • ApplicationViewMode.png-dark
    • ApplicationViewMode.png
    • AppWindowClosing.png
    • AppWindowPositionAndSize.png-dark
    • AppWindowPositionAndSize.png
    • Arrange_Performance01.png
    • Attributed_text_FontSize_Changing.png-dark
    • AuthenticationBroker_Demo.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutomationProperties_AutomationId.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • 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.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 26s —— View job


Review complete ✅

  • Gather context (PR diff, AGENTS.md, changed files)
  • Review Accessibility.ts change
  • Review new runtime test in Given_AccessibleScrollViewer.cs
  • Check cross-cutting concerns
  • Post inline findings (none — see notes below)
  • Post summary

Verdict: ship. No commits have changed since the prior reviews on this PR (d5078b7d / 7731d69e, matching the cac616dc / 2fbc9c74 file SHAs already reviewed) — I independently re-verified the full diff against AGENTS.md and the path-scoped rules and found 0 inline findings (0 blocking, 0 non-blocking line-level issues).

What I checked:

  • Both .focus() call sites in focusSemanticElement (immediate path and the requestAnimationFrame retry) correctly pass { preventScroll: true }, matching the existing pattern in BrowserInvisibleTextBoxViewExtension.ts. The added comment explains the non-obvious why (scroll feedback into ScrollViewer) without narrating the change itself, per code-style.md.
  • focusSemanticElement is the single interop entry point for all native-focus-mirroring call sites, so the fix applies uniformly with no duplication needed elsewhere.
  • The new test When_Programmatic_Focus_Outside_Viewport_Then_Not_Scrolled follows runtime-tests.md conventions: [RunsOnUIThread] + async Task (it awaits), [PlatformCondition(Include, SkiaWasm)] rather than #if on the method, sits correctly inside the existing #if HAS_UNO region, and asserts both the DOM signal (scrollTop walked up the ancestor chain) and the XAML signal (ScrollViewer.VerticalOffset). Per the PR description this was verified red-before/green-after against the real bug, satisfying the root-cause-first validation protocol in debugging-discipline.md — this is a root-cause fix (removing the browser-initiated scroll trigger), not a guard.
  • Tabs/Allman braces, commit messages (Conventional Commits: fix(a11y), test(a11y)), and no new warnings/#pragma/NoWarn growth.
  • Checked the extra blank lines before #endif near the end of Given_AccessibleScrollViewer.cs: confirmed via git show origin/master:... that these predate this PR (not introduced by this diff), so not flagged as a finding here.

Non-blocking, out of scope for this PR (already disclosed in the PR description):

  • SemanticElements.ts (arrow-key nav) and FocusTrap.ts still call plain .focus() without preventScroll. Reasonable to leave as a tracked follow-up since keyboard navigation arguably should bring the item into view, unlike this programmatic-mirroring path.
  • Accessibility.ts's focus-trap departure sentinel (sentinel.focus()) is also uncovered, but the sentinel is position: fixed; top:0; left:0 and effectively always in-viewport, so it's unlikely to trigger a scroll in practice.
    · Branch

Copilot AI left a comment

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 3 Medium severity

Open (3)
What changed in this PR

Prevents the browser from auto-scrolling semantic DOM containers when XAML focus is mirrored into the DOM in WASM accessibility mode, avoiding scroll feedback loops into ScrollViewer.

Changes:

  • Use element.focus({ preventScroll: true }) (including the retry path) when focusing semantic DOM nodes.
  • Add a WASM runtime test asserting that programmatic focus does not scroll the semantic scroller or the XAML ScrollViewer.
File Description
src/​Uno.UI.RuntimeTests/​Microsoft/​UI/​Xaml/​Automation/​Given_AccessibleScrollViewer.cs Adds a regression test ensuring semantic focus mirroring doesn’t produce browser-driven scrolling.
src/​Uno.UI.Runtime.Skia.WebAssembly.Browser/​ts/​Runtime/​Accessibility.ts Updates semantic DOM focusing to prevent browser auto-scroll during focus mirroring.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237168 found UI Test snapshots differences: skia-linux-screenshots: 119, skia-windows-screenshots: 133

Details
  • skia-linux-screenshots: 119 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • DisplayInformation.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
  • skia-windows-screenshots: 133 changed over 2456

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DisplayInformation.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • ElementLevelTheme.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Grid_InsideStackPanel_InsideButton.png-dark
    • Grid_InsideStackPanel_InsideButton.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ImageBrushInList.png-dark

Copilot AI balanced review requested due to automatic review settings October 6, 2026 09:46
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/flaky-wasm-gotfocus branch from 7731d69 to a0d4363 Compare October 6, 2026 09:46

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 15s —— View job


Review complete ✅

Verdict: ship. 0 inline findings (0 blocking, 0 non-blocking). I reviewed from the PR description and the earlier automated reviews, and I did not re-read the diff or run any code in this pass.

Fix

  • focusSemanticElement now passes { preventScroll: true } on both .focus() calls, the immediate one and the requestAnimationFrame retry. This removes the trigger for the browser-initiated scroll, so it is a root-cause fix and not a guard.
  • It follows the same pattern as the text-input extension.

Copilot's open comments

  • focus({ preventScroll }) throwing on browsers without FocusOptions: I don't think this is a real risk. Per the WebIDL dictionary rules, unknown or unsupported dictionary members are silently ignored. preventScroll is also supported in every browser Uno WASM targets (WASM and Skia need modern evergreen browsers). A try/catch fallback would add code with no practical benefit, so I would not add it.
  • Test reads scrollTop immediately after Focus(), so it could give a false pass: per the PR description, the test fails without the fix (scrollTop 1877 instead of 0) and passes with it, so it does catch the regression. The browser scrolls synchronously on focus(). The diagnostic in the description also shows the scroll landing within 3 ms of Focus(). A short post-wait would be harmless extra safety, but I don't see it as required.

Non-blocking, out of scope

  • Plain .focus() calls remain in SemanticElements.ts and FocusTrap.ts, as the description already discloses. They are also in the focus-trap sentinel in Accessibility.ts. Keyboard navigation arguably should bring the item into view, so a follow-up issue is reasonable.
  • The blank lines before the closing #endif in the test file were already there before this PR.
  • The screenshot-diff comments from CI look unrelated to this change, since it only touches the WASM semantic DOM focus path and a runtime test.
    · Branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237628 found UI Test snapshots differences: skia-linux-screenshots: 130, skia-windows-screenshots: 165

Details
  • skia-linux-screenshots: 130 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
  • skia-windows-screenshots: 165 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DeferLoadStrategyWithTemplateBinding.png-dark
    • DeferLoadStrategyWithTemplateBinding.png
    • DisplayInformation.png-dark
    • GridWithColumnSpan.png-dark
    • GridWithColumnSpan.png
    • Grid_Auto_Center_Cell.png-dark
    • Grid_Auto_Center_Cell.png
    • Grid_Auto_Text_Block_Trimming.png-dark
    • Grid_Auto_Text_Block_Trimming.png
    • Grid_CenteredShapes.png-dark
    • Grid_CenteredShapes.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark

MartinZikmund and others added 3 commits October 9, 2026 14:51
Focusing a semantic node let the browser scroll its semantic scroller
to reveal it, and the scroll listener fed that offset back into the
ScrollViewer. Programmatic focus of an off-screen element then scrolled
the XAML content, flaking Given_TextBox.When_GotFocus_BringIntoView on
WASM once accessibility is enabled.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 13:26
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/flaky-wasm-gotfocus branch from a0d4363 to 7c06b30 Compare October 9, 2026 13:26

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 13s —— View job


Review complete

Verdict: ship. 0 inline findings (0 blocking, 0 non-blocking).

I re-read the TypeScript diff in this pass. I did not re-read the test file or run any code.

Fix

  • Both .focus() calls in focusSemanticElement now pass { preventScroll: true }. That covers the immediate call and the requestAnimationFrame retry.
  • It removes the browser-initiated scroll that the scroll listener fed back into the ScrollViewer. That makes it a root-cause fix, not a guard.
  • The comment explains why XAML must own scrolling and doesn't describe the change.

Copilot's open comments

  • focus({ preventScroll }) throwing on browsers without FocusOptions: I wouldn't add a try/catch. WebIDL dictionaries ignore unknown members, and preventScroll is supported in every evergreen browser Uno WASM targets.
  • Test reading scrollTop immediately after Focus(): the PR description says the test fails without the fix (scrollTop 1877 instead of 0) and passes with it. Browsers scroll synchronously on focus(), so the immediate read is a valid check. A short post-wait would be harmless extra safety, but it isn't required.

Out of scope

  • Plain .focus() calls remain in SemanticElements.ts, FocusTrap.ts and the focus-trap sentinel in Accessibility.ts. The PR description already discloses these, and keyboard navigation arguably should bring the item into view. A follow-up issue is reasonable.
  • The screenshot-diff CI comments look unrelated to this change. It only touches the WASM semantic DOM focus path and a runtime test.
    · Branch

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238540 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 1144

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ElementLevelTheme.png-dark
  • skia-windows-screenshots: 1144 changed over 2474

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutoBorderStretchwithrightmargin.png
    • BackGesture.png-dark
    • BackGesture.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • Border_LinearGradientBrush.png-dark
    • Border_LinearGradientBrush.png
    • Border_Simple.png-dark
    • Border_Simple.png
    • Button_Opacity_Automated.png-dark
    • Button_Opacity_Automated.png
    • ColorAnimationUsingKeyFrames_Fill.png-dark
    • ColorAnimationUsingKeyFrames_Fill.png
    • ComboBox_DropDownPlacement.png-dark
    • ComboBox_DropDownPlacement.png
    • ComboBox_Popover.png-dark

@MartinZikmund
MartinZikmund merged commit 31777b0 into master Oct 9, 2026
50 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/flaky-wasm-gotfocus branch October 9, 2026 21:36
@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] Programmatic focus scrolls the ScrollViewer when accessibility is enabled

5 participants