Skip to content

[WinUI] Fix CollectionView accessibility and focus restoration using ItemsRepeater - #38723

Merged
kubaflo merged 24 commits into
net11.0from
Fix-customautionpeer
Sep 28, 2026
Merged

kubaflo merged 24 commits into
net11.0from
Fix-customautionpeer

Conversation

@SuthiYuvaraj

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Description

CollectionView on WinUI is implemented using ItemsRepeater. While ItemsRepeater provides virtualization and item realization, it does not provide the complete accessibility and keyboard navigation behavior expected by CollectionView.

There are two primary issues:

1. Focus Restoration

ItemsRepeater does not track the last focused item or provide APIs to restore focus to a specific item. When keyboard navigation returns to the CollectionView, there is no built-in mechanism to determine which item should regain focus.

Additionally, due to virtualization, the target item may not be realized at the time focus is requested, preventing focus from being applied immediately.

2. Selection and Keyboard Navigation

ItemsRepeater does not support SingleSelectionFollowFocus.

In SelectionMode.Single, keyboard navigation using Tab and Arrow keys can trigger selection-related behavior that differs from the expected CollectionView experience.

WinUI's selection-follow-focus implementation assumes that the selected item is a native UIElement. In .NET MAUI, the selected item is typically a bound data object. This mismatch can result in an invalid COM cast and cause an E_NOINTERFACE ("No such interface supported") exception during keyboard navigation.

Root Cause

ItemsView is responsible for selection and current-item semantics:

  • It owns SelectionMode and selected-item state.
  • It tracks the current item through CurrentItemIndex.
  • It is expected to provide an accessible keyboard navigation experience.

ItemsRepeater, however, is only responsible for realizing and recycling item containers. It does not maintain selection, current-item state, or focus restoration behavior required by CollectionView.

Fix Description

  • Set item containers as accessibility elements so they participate correctly in accessibility and keyboard navigation scenarios.
  • Configure MauiItemsView as a tab stop after the control is loaded, allowing keyboard users to re-enter the control.
  • Introduce a custom AutomationPeer for MauiItemsView to provide CollectionView-specific accessibility behavior not available through ItemsRepeater.
  • Add ItemsViewAccessibilityHelper to:
    • Track the currently focused item.
    • Restore focus when keyboard navigation re-enters the control.
    • Coordinate focus behavior independently of ItemsRepeater virtualization.
  • Handle element preparation events to support focus restoration for virtualized items that are not yet realized. Focus is applied automatically once the target container becomes available.

Issues Fixed

Fixes #38660

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before Issue Fix After Issue Fix
Issuereport.mp4
fixAfterTrim.mp4

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38723

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38723"

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Sep 21, 2026
@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

/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.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15394816 is running for windows.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 2 findings

See inline comments for details.


foreach (var nativeItem in itemList)
{
var nativeItem = itemList[index];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness — The new multi-select synchronization loop redeclares nativeItem inside foreach (var nativeItem in itemList), which is a C# scope error (CS0136) and breaks compilation for this handler. The current change also never advances index, so the intended index-based selection sync cannot work as written.


protected override void OnApplyTemplate()
{
CleanUpAccessibilityHelper();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Accessibility — OnApplyTemplate() now calls CleanUpAccessibilityHelper() but never re-subscribes GettingFocus. Concrete failure: after template application/reapplication, keyboard Tab focus no longer redirects into the selected/first item, so CollectionView keyboard navigation/accessibility behavior regresses on subsequent focus entry.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Sep 21, 2026
@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@sheiksyedm

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 21, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Sep 24, 2026
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@SuthiYuvaraj — test-failure analysis for commit f2699b2.

Scope CI failures Commit f2699b2


🧪 CI Analysis — click to expand

Evaluation skipped: no usable current-PR results.

📊 maui-pr

Pending; no results yet.


🧪 maui-pr-devicetests

No current-PR results available.


🧪 maui-pr-uitests

No current-PR results available.


🧭 Follow-up — actions and refresh

Next action: Comment /azp run to run CI (wait if it is already running).

Maintainers: comment /review tests to refresh this report.

@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

/azp run

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15448140 is running for windows.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@SuthiYuvaraj — new AI review results are available based on commit f2699b2.

Gate Inconclusive Confidence Low Platform Windows


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ⚠️ INCONCLUSIVE

Platform: WINDOWS · Base: net11.0 · Merge base: b10b2ecb

🩺 Pre-existing build failure (not the fix) — both the without-fix baseline AND the with-fix build fail with a build error, so the PR's fix is NOT the cause. This is a broken main/merge-base or a toolchain/environment failure (e.g. an ILLink IL1012 trimmer crash). The gate cannot verify anything; investigate the build environment rather than the PR.

D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recogniz...

Test Without Fix (expect FAIL) With Fix (expect PASS)
📱 CollectionViewTests (CollectionView2RestoresFocusToLastFocusedItem, CollectionView2FocusesSelectedItemOnFirstEntry) Category=CollectionView 🛠️ BUILD ERROR 🛠️ BUILD ERROR
🔴 Without fix — 📱 CollectionViewTests (CollectionView2RestoresFocusToLastFocusedItem, CollectionView2FocusesSelectedItemOnFirstEntry): 🛠️ BUILD ERROR · 13s

Error-relevant lines (filtered from the build log):

D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\tests\DeviceTests.Shared\Core.DeviceTests.Shared.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\TestUtils\src\DeviceTests\TestUtils.DeviceTests.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\TestUtils\src\DeviceTests.Runners\TestUtils.DeviceTests.Runners.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\src\Core.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\maps\src\Maps.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\src\Xaml\Controls.Xaml.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\Maps\src\Controls.Maps.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Graphics\src\Graphics\Graphics.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net11.0-ios]
🟢 With fix — 📱 CollectionViewTests (CollectionView2RestoresFocusToLastFocusedItem, CollectionView2FocusesSelectedItemOnFirstEntry): 🛠️ BUILD ERROR · 14s

Error-relevant lines (filtered from the build log):

D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\tests\DeviceTests.Shared\Core.DeviceTests.Shared.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\TestUtils\src\DeviceTests.Runners\TestUtils.DeviceTests.Runners.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\TestUtils\src\DeviceTests\TestUtils.DeviceTests.csproj::TargetFramework=net11.0-ios]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\src\Core.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Core\maps\src\Maps.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\src\Xaml\Controls.Xaml.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\Maps\src\Controls.Maps.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Graphics\src\Graphics\Graphics.csproj::TargetFramework=net11.0-ios26.5]
D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recognized. [D:\a\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net11.0-ios]

⚠️ Failure Details

  • 🛠️ CollectionViewTests (CollectionView2RestoresFocusToLastFocusedItem, CollectionView2FocusesSelectedItemOnFirstEntry) without fix: build failed before tests could run
    • D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recogniz...
  • 🛠️ CollectionViewTests (CollectionView2RestoresFocusToLastFocusedItem, CollectionView2FocusesSelectedItemOnFirstEntry) with fix: build failed (fix does not compile)
    • D:\a\1\s\.dotnet\sdk\11.0.100-rc.2.26470.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(133,5): error NETSDK1139: The target platform identifier ios was not recogniz...
📁 Fix files reverted (5 files)
  • src/Controls/src/Core/Handlers/Items2/CollectionViewHandler2.Windows.cs
  • src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.Windows.cs
  • src/Controls/src/Core/Handlers/Items2/Windows/ItemFactory.cs
  • src/Controls/src/Core/Handlers/Items2/Windows/MauiItemsView.cs
  • src/Controls/src/Core/Platform/Windows/CollectionView/ItemsViewStyles.xaml

New files (not reverted):

  • src/Controls/src/Core/Handlers/Items2/Windows/ItemsViewAccessibilityHelper.cs
  • src/Controls/src/Core/Handlers/Items2/Windows/MauiItemsViewAutomationPeer.cs

📋 Pre-Flight — Context & Validation

PR #38723 Pre-Flight

Context

  • PR: [WinUI] Fix CollectionView accessibility and focus restoration using ItemsRepeater
  • Issue: #38660, a Windows CollectionView2 regression introduced in .NET 11 preview 6. Keyboard Tab navigation skips the CollectionView, item focus/navigation is unreliable, and screen readers do not announce item semantic descriptions/hints.
  • Base / review commit: net11.0 at b10b2ecb; squashed review commit 848bf9af6b.
  • Active path: src/Controls/src/Core/Handlers/Items2/** is the default .NET 11 Windows CollectionView handler. The legacy Items/** path is out of scope.

Existing PR Approach

The PR changes nine files (+858/-22), including two new production files:

  • CollectionViewHandler2.Windows.cs wires and tears down accessibility/focus state.
  • ItemsViewHandler2.Windows.cs, MauiItemsView.cs, and ItemFactory.cs expose realization events, keep automation set metadata current, and refresh item semantic properties.
  • New ItemsViewAccessibilityHelper.cs tracks the last focused item, redirects keyboard entry, waits for virtualized containers to be prepared, queues focus, and falls back to the selected or first realized item.
  • New MauiItemsViewAutomationPeer.cs supplies CollectionView identity/pattern behavior.
  • ItemsViewStyles.xaml changes native focus/tab behavior.
  • Device tests explicitly register CollectionViewHandler2 and add the two focus regressions below.

An alternative must use a different root-cause mechanism, not merely move the same last-focused-index/container-prepared state machine to another file.

Required Validation

Platform: windows. Run only the Controls device-test project with a filter selecting both methods:

pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform windows -TestFilter "FullyQualifiedName~CollectionView2RestoresFocusToLastFocusedItem|FullyQualifiedName~CollectionView2FocusesSelectedItemOnFirstEntry"

Mandatory regression tests:

  1. CollectionViewTests.CollectionView2RestoresFocusToLastFocusedItem
  2. CollectionViewTests.CollectionView2FocusesSelectedItemOnFirstEntry

Do not run the full suite and do not rerun gate verification.

Existing Evidence and Constraints

  • Gate result is INCONCLUSIVE, not a fix failure. Both baseline and PR builds stop before tests with NETSDK1139 because the Windows environment does not recognize iOS target platform identifiers.
  • Regression cross-reference found no overlap with recent labeled bug-fix PRs touching these files.
  • The try-fix baseline boundary is significant: the PR introduces ItemsViewAccessibilityHelper.cs and MauiItemsViewAutomationPeer.cs. If EstablishBrokenBaseline.ps1 records either in NewFiles, the try-fix skill requires a truthful Blocked result before editing, followed by its mandatory restore.
  • Pre-existing dirty script files are harness-owned and unrelated; do not alter, restore, or delete them.
  • Follow the Windows CollectionView, handler-detection, handler, performance-hotpath, threading, public-API, and device-test repository instructions for any eligible edit.

🔬 Code Review — Deep Analysis

Expert Evaluation — Submitted PR

Verdict: NEEDS_DISCUSSION
Confidence: low

The submitted Windows CollectionView2 fix adds keyboard focus restoration, accessibility metadata, a MauiItemsView automation peer, lifecycle cleanup/reattachment, and focused regression coverage. The expert review found no actionable error, warning, or suggestion on the added or modified lines; inline-findings.json therefore contains an empty JSON array.

The implementation's lifecycle and virtualization paths are internally coherent: disconnect/reconnect reattaches the helper without accumulating subscriptions, pending focus work is cancelled when state changes, template reapplication removes prior repeater event handlers, and deferred focus is tied to realization of the intended item. Accessible prior error-level review concerns were found to be addressed by the submitted head.

The review cannot recommend unconditional approval from code evidence alone because the trusted Gate is inconclusive (NETSDK1139 prevented the required Windows device tests from building or running). This is an evidence gap, not a regression-test failure and not an identified defect in the fix.

Findings

No actionable inline findings.

Blast Radius and Failure-Mode Probing

  • The behavior is confined to the Windows CollectionView2 handler path, but it runs for all instances on that path.
  • No new global/static mutable state is introduced.
  • Handler disconnect/reconnect is symmetric: cleanup removes subscriptions and reconnect reattaches the helper.
  • Items-source changes and pending virtualized-container focus requests cancel stale deferred work.
  • Template reapplication cleans repeater automation handlers before adding replacements.
  • Null or unrealized focus targets use guarded fallback/deferred paths rather than unconditional platform access.

Validation Status

The Gate result remains INCONCLUSIVE. It must not be interpreted as either a passing or failing candidate.


🛠️ Try-Fix — Analysis & Comparison

Candidate 1 Try-Fix Narrative (PR #38723)

Status

Blocked before edits or tests.

Approach Description

Candidate 1 executed the mandatory try-fix workflow and first attempted to establish the broken baseline. Baseline creation failed because eight pre-existing dirty tracked script files made the working directory ineligible. No .github/.baseline-state.json was created, so there was no RevertedFiles edit allow-list.

Prior Approach Avoided and Mechanism-Level Difference

The existing PR uses an ItemsViewAccessibilityHelper state machine: it tracks the last-focused integer index, intercepts GettingFocus, waits for ContainerPrepared when virtualization hides a target, and queues explicit focus. It also adds a custom automation peer and semantic metadata wiring. Candidate 1 did not implement, relocate, or rewrite that mechanism. Its only difference was procedural safety enforcement: it stopped before mutation when baseline restoration guarantees were unavailable. Candidate 1 therefore produced no fix mechanism to repeat or compare behaviorally.

Files Changed

No production, source, test, or pre-existing dirty files were changed. Candidate 1 created only its required attempt artifacts under:

CustomAgentLogsTmp/PRState/38723/PRAgent/try-fix/attempt-1/

Those artifacts were baseline.log, approach.md, reviewer-findings.json, reviewer-findings.diff, result.txt, fix.diff, test-output.log, and analysis.md.

Exact Captured Diff

The candidate diff was empty.

Test Command and Results

Required command:

pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform windows -TestFilter "FullyQualifiedName~CollectionView2RestoresFocusToLastFocusedItem|FullyQualifiedName~CollectionView2FocusesSelectedItemOnFirstEntry"

The command was not executed because Step 2 failed before a safe baseline and editable allow-list existed. Candidate 1 ran no other tests.

Failure / Blocker Analysis

EstablishBrokenBaseline.ps1 reported that the working directory was not clean because of eight pre-existing dirty tracked script files. The baseline log had no Baseline established marker, and .github/.baseline-state.json was absent. Under the try-fix boundary, source edits and testing were forbidden. This was a safety blocker, not a behavioral result for a proposed fix.

Self-Review

0 findings. reviewer-findings.json contained []; there was no candidate diff to review.

Restoration Result

Exact command executed:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

Output reported No baseline state found and Restored: False. That was the expected result for the verified no-state path, and Candidate 1 made no attempt edits.

Candidate 2 Try-Fix Narrative (PR #38723)

Status

Blocked before edits or tests.

Approach / Intended Approach: Native Roving ItemContainer Tab Stop

Candidate 2's intended alternative treats the regression as a broken WinUI tab-candidate graph, rather than a missing programmatic focus request. The proposed mechanism would keep the MauiItemsView owner, wrapper, and repeater out of the tab order and make exactly one realized data ItemContainer the native tab stop. Initial realization would seed that active stop from the selected item, falling back to the first data item. When keyboard focus moves to another item, the native focus event would transfer the tab-stop role to that container. After focus leaves the CollectionView, WinUI's normal tab traversal would therefore re-enter the currently active container.

The likely eligible implementation locations would have been the existing ItemFactory.cs container setup/recycle path and ItemsViewStyles.xaml tab configuration, subject to the baseline RevertedFiles allow-list. No implementation was permitted because that allow-list was never created.

Candidate 1 Result Avoided and Mechanism-Level Difference

Candidate 1 was blocked at baseline, made no edits, ran no tests, and supplied no fix mechanism. Candidate 2 did not inspect Candidate 1's attempt directory; it used only the recorded Candidate 1 result. Although the same unchanged worktree caused the same mandatory safety block, Candidate 2 independently identified a concrete native-container alternative rather than treating the safety block as a solution.

The PR's helper reconstructs focus from an integer index: it cancels GettingFocus, may scroll the target into view, subscribes to ContainerPrepared, and dispatches an explicit Focus call guarded by queued-state and cancellation state. The intended roving-tab-stop mechanism instead changes WinUI's native focus candidate graph as containers are realized and focused. Normal keyboard traversal itself would select the selected/last-active container. It would not cancel entry, recover an index, wait for ContainerPrepared, queue focus, or use a helper focus state machine. This is a different cause-to-effect chain, not a relocation or light rewrite of the PR helper.

Baseline Establishment

Exact command executed:

pwsh .github/scripts/EstablishBrokenBaseline.ps1

It exited with code 1 and reported DIRTY WORKING DIRECTORY - Cannot establish baseline. The eight pre-existing tracked paths were:

  • .github/scripts/CopilotPipeline.Tests.ps1
  • .github/scripts/Review-PR.Tests.ps1
  • .github/scripts/RunTests.ps1
  • .github/scripts/Set-ScreenResolution.Tests.ps1 (pre-existing deletion)
  • .github/scripts/shared/Detect-TestsInDiff.ps1
  • .github/skills/verify-tests-fail-without-fix/scripts/verify-tests-fail.ps1
  • eng/scripts/Set-ScreenResolution.ps1
  • eng/scripts/update-cgmanifest.ps1

Verification found no Baseline established marker and confirmed .github/.baseline-state.json did not exist. Consequently there was no RevertedFiles allow-list. The skill requires Blocked before any tracked edit on this verified no-state path.

Files Changed

No production, source, test, or pre-existing dirty files were changed.

Required attempt artifacts were created under:

CustomAgentLogsTmp/PRState/38723/PRAgent/try-fix/attempt-2/

including baseline.log, approach.md, reviewer-findings.json, reviewer-findings.diff, result.txt, fix.diff, test-output.log, analysis.md, and restore.log. result.txt contains Blocked.

Exact Candidate Diff

The candidate-scoped diff is explicitly empty. The unrelated eight dirty tracked script paths pre-dated this attempt and were preserved; they are not candidate changes.

Test Command and Results

Only allowed command:

pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform windows -TestFilter "FullyQualifiedName~CollectionView2RestoresFocusToLastFocusedItem|FullyQualifiedName~CollectionView2FocusesSelectedItemOnFirstEntry"

The command was not executed because mandatory Step 2 failed before creating an editable baseline. Therefore neither CollectionViewTests.CollectionView2RestoresFocusToLastFocusedItem nor CollectionViewTests.CollectionView2FocusesSelectedItemOnFirstEntry ran. Candidate 2 ran no other test or build command and did not rerun gate verification. There is no behavioral Pass/Fail claim and no new NETSDK1139 result; the attempt status is solely Blocked by baseline safety.

Failure / Blocker Analysis

The baseline script rejects any dirty tracked worktree and did so before reverting the PR files. Since it created no state file, script-only restoration could not track or safely restore an implementation. Editing either existing or newly added PR production files would have violated the absolute baseline boundary. Candidate 2 therefore stopped before code mutation, as required. This does not disprove the intended native roving-tab-stop hypothesis; it means the hypothesis could not be implemented or empirically evaluated in this worktree.

Expert Self-Review

0 findings (reviewer-findings.json is []). Candidate 2 reviewed the eight overarching principles and the always-active Logic and Correctness, Regression Prevention, and Complexity Reduction dimensions inline. Because the candidate diff is empty, there was no changed line on which to record a finding. The test loop made no code changes, so the self-review remained current and no refresh was required. Self-review finding count: 0 (one inline review pass).

Restoration Result

After the artifact gate passed, Candidate 2 executed exactly:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

Output:

No baseline state found. Nothing to restore.
Message  No baseline state found
Restored False

This is the required and accepted restoration outcome for a verified no-state path with no attempt edits. A post-restore verification confirmed .github/.baseline-state.json remained absent and git status --short still listed exactly the same eight pre-existing dirty tracked script paths. No pre-existing dirty or untracked path was altered.

Final Result

  • Result: Blocked
  • This attempt's status: Done
  • Reasoning: The one intended alternative was fully identified, but baseline safety preconditions failed before implementation or testing. The required artifacts and narrative were captured, and the exact restore command completed with the expected verified no-state outcome.

🏁 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Winner

pr — the raw submitted PR fix.

The submitted implementation is the only substantive completed fix. The single expert review found no actionable diff-level findings, and its failure-mode analysis confirmed coherent handling of reconnects, stale deferred focus work, template reapplication, virtualization, and selection/focus separation. The trusted Gate is INCONCLUSIVE, so the behavior remains unverified; however, this is an environment/build limitation (NETSDK1139), not a failed regression result, and the Gate instructions explicitly prohibit requesting changes solely for that outcome.

Candidate Comparison

Rank Candidate Implementation Expert review Required regression tests Assessment
1 pr Complete submitted Windows CollectionView2 accessibility/focus fix No actionable findings Not built or run; Gate INCONCLUSIVE Best candidate on code merit; no source change was identified
2 pr-plus-reviewer Identical production/test behavior to pr; reviewer.patch is empty No feedback existed to apply Not run because the conditional refinement step was not triggered Correct but provides no improvement over the raw PR
3 try-fix-2 No diff; only an unimplemented roving-tab-stop design Empty-diff self-review found nothing Not run; candidate was Blocked before edits Interesting hypothesis, but no code or behavioral evidence
4 try-fix-1 No diff and no alternative mechanism Empty-diff self-review found nothing Not run; candidate was Blocked before edits Procedurally safe but not a fix candidate

No candidate passed or failed the regression tests. The raw PR and pr-plus-reviewer inherit the same inconclusive Gate evidence; both try-fix candidates were blocked before testing. Therefore the rule that a regression-test failure ranks below a pass does not alter this ordering.

Why pr Wins

  • It directly addresses the active .NET 11 Windows CollectionView2 handler path.
  • It supplies the focus-restoration state machine, automation peer behavior, semantic metadata updates, lifecycle cleanup/reattachment, and focused device tests described by the issue.
  • The expert review produced [] in inline-findings.json; no consolidated refinement was justified.
  • Choosing the identical pr-plus-reviewer copy would falsely imply that reviewer-authored changes are needed.
  • Neither try-fix candidate contains an executable implementation or test result.

Remaining Uncertainty

The two required Windows device tests did not execute because the environment failed before test execution with NETSDK1139. Approval here is a code-review recommendation, not a claim that the regression tests passed; CI or a compatible Windows environment still needs to establish behavioral verification.


📱 UI Tests — CollectionView

Detected UI test categories: CollectionView

[!WARNING]
No UI test results were produced for the detected categories. The trusted gate was
inconclusive and did not establish whether the PR build was healthy. The deep UI stage also
returned no results, usually because of a build, environment, or infrastructure interruption;
inspect the Gate section and independent CI checks before retrying.


🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR s/agent-review-in-progress AI review is currently running for this PR labels Sep 24, 2026

@kubaflo kubaflo 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.

Could you please check the ai's suggestions?

@kubaflo
kubaflo enabled auto-merge (squash) September 28, 2026 17:14
@kubaflo
kubaflo disabled auto-merge September 28, 2026 17:14
@kubaflo
kubaflo merged commit 328551f into net11.0 Sep 28, 2026
5 of 14 checks passed
@kubaflo
kubaflo deleted the Fix-customautionpeer branch September 28, 2026 17:19
@github-actions github-actions Bot added this to the .NET 11.0-rc2 milestone Sep 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-winui-cv2 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants