[Android] Fixed selection logic with header/footer in CollectionView#32215
[Android] Fixed selection logic with header/footer in CollectionView#32215kubaflo wants to merge 2 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for intercepting web resource requests in BlazorWebView across iOS, Windows, and Android platforms. The changes enable applications to customize or override resource loading behavior through a new WebResourceRequested event.
Key changes:
- Added a new public API
WebResourceRequestedevent toBlazorWebViewfor intercepting web resource requests - Implemented platform-specific request interception mechanisms for iOS, Windows, and Android
- Fixed iOS-specific issues including deprecated API usage and JavaScript text input panel handling
- Updated localization files across multiple languages
Reviewed Changes
Copilot reviewed 293 out of 3941 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/BlazorWebView/src/Maui/iOS/IOSWebViewManager.cs | Implemented custom text input panel handler and added request interception support |
| src/BlazorWebView/src/Maui/iOS/BlazorWebViewHandler.iOS.cs | Added webview scrolling configuration and request interception logic |
| src/BlazorWebView/src/Maui/Windows/WinUIWebViewManager.cs | Integrated request interception into Windows WebView2 request handling |
| src/BlazorWebView/src/Maui/PublicAPI/*/PublicAPI.Unshipped.txt | Documented new public API surface for WebResourceRequested event |
| src/BlazorWebView/src/Maui/IBlazorWebView.cs | Extended interface to support web request interception |
| src/BlazorWebView/src/Maui/BlazorWebView.cs | Implemented WebResourceRequested event and interface methods |
| src/BlazorWebView/src/Maui/Android/WebKitWebViewClient.cs | Refactored request handling to support interception |
| src/BlazorWebView/src/Maui/Android/BlazorWebViewHandler.Android.cs | Updated type references to use global namespace qualifiers |
| src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.cs | Updated type references to use global namespace qualifiers |
| src/BlazorWebView/samples/BlazorWpfApp/BlazorWpfApp.csproj | Updated target framework to include Windows SDK version |
| src/BlazorWebView/samples/BlazorWinFormsApp/BlazorWinFormsApp.csproj | Removed unnecessary IsTestProject property |
| src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj | Enabled unsafe blocks and removed unused file link |
| loc/**/templatestrings.json.lcl | Updated localization files with translations and metadata |
| loc/**/MauiGResources.resx.lcl | Added new localized error messages for XAML parsing |
| loc/**/ErrorMessages.resx.lcl | Updated localized error message translations |
| loc/**/StringResources.resx.lcl | Updated localized UI string translations |
Comments suppressed due to low confidence (1)
src/BlazorWebView/src/Maui/BlazorWebView.cs:1
- Corrected spelling of 'ReponseContentNotFound' to 'ResponseContentNotFound'.
using System;
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
left a comment
There was a problem hiding this comment.
This is the tests validating the fix?
Exactly, it is |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
e430d0b to
82c908a
Compare
|
I would like to test the artifact from this pr but some checks are 'Waiting for status to be reported'. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
82c908a to
6528786
Compare
|
Our company app cannot upgrade to .NET 10 because of this bug. We urgently need this PR to be merged. Thank you. |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 32215Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 32215" |
|
|
Adjusted SelectableItemsViewAdapter to correctly handle selection when header or footer templates are present. Updated Issue21375 test case to include header and footer templates.
🤖 AI Summary📊 Expand Full Review —
|
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #32215 | Skip header/footer adapter positions before reading items during Android selection marking, and extend Issue21375 HostApp content to include header/footer templates | ⏳ PENDING (Gate) | src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs, src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml, src/Controls/tests/TestCases.Android.Tests/snapshots/android/SelectedItemsShowSelected_single.png |
Original PR |
Issue: #32212 - [Android][.NET9] Selecting error when there is a FooterTemplate
PR: #32215 - [Android] Fixed selection logic with header/footer in CollectionView
Platforms Affected: Android
Files Changed: 1 implementation, 2 test
Key Findings
- The linked issue reports an Android
ArgumentOutOfRangeExceptionwhen selecting aCollectionViewitem while a header/footer template is present; a later issue comment confirms the same failure pattern withHeaderTemplateon .NET 10. - The PR modifies
src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.csand extends the existingIssue21375HostApp page with both header and footer templates. - The existing validation surface is the UI test
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21375.cs, which already exercises single, multiple, and none selection screenshots on Android. - PR discussion explicitly confirms
Issue21375is the intended test. A prior agent review summary exists on the PR and previously reported gate trouble around screenshot validation, so this rerun should pay close attention to whether the Android baselines are fully aligned.
Edge Cases Noted
- FooterTemplate selection crash from the original issue reproduction.
- HeaderTemplate appears to hit the same failure mode per follow-up issue comment.
- The UI test switches between
Single,Multiple, andNoneselection modes, so any visual or state-sync regression can show up beyond the first tap.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #32215 | Skip header/footer adapter positions before reading items during Android selection marking, and extend Issue21375 HostApp content to include header/footer templates |
⏳ PENDING (Gate) | src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs, src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml, src/Controls/tests/TestCases.Android.Tests/snapshots/android/SelectedItemsShowSelected_single.png |
Original PR |
🚦 Gate — Test Verification
Gate Result: ❌ FAILED
Platform: android
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ❌
Notes
- The verification established a broken baseline without the fix:
Issue21375fails because the app crashes during the selection flow, matching the reported Android CollectionView regression. - With the PR fix applied, the crash no longer appears to be the blocking symptom, but the verification still fails because the screenshot baseline for
SelectedItemsShowSelected_multiple.pngdiffers by 1.79%. - The verification also reported an Android deployment instability (
Broken pipe (32)during package install) on the second pass, so the environment may be contributing noise, but Gate remains failed because the test suite did not cleanly pass with the fix.
Gate Result: ❌ FAILED
Platform: android
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ❌
Notes
- The verification script confirmed the Android
Issue21375test fails without the fix, so the test does reproduce the bug. - The verification did not achieve a clean pass with the PR applied. The captured UI test output shows fixture-setup instability (
Selected CollectionView item is not announced), and follow-up try-fix runs consistently showed that once the crash path is avoided, Android snapshot validation still fails unless_multipleand_nonebaselines are refreshed. - Net result: the PR does not currently produce a clean Android verification pass as submitted.
🔧 Fix — Analysis & Comparison
Gate Result: ❌ FAILED
Platform: android
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ❌
Notes
- The verification established a broken baseline without the fix:
Issue21375fails because the app crashes during the selection flow, matching the reported Android CollectionView regression. - With the PR fix applied, the crash no longer appears to be the blocking symptom, but the verification still fails because the screenshot baseline for
SelectedItemsShowSelected_multiple.pngdiffers by 1.79%. - The verification also reported an Android deployment instability (
Broken pipe (32)during package install) on the second pass, so the environment may be contributing noise, but Gate remains failed because the test suite did not cleanly pass with the fix.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | try-fix | Filter header/footer holders out in OnBindViewHolder so non-data holders never enter _currentViewHolders |
❌ FAIL | 1 file | Prevented the crash path; Android test still failed on SelectedItemsShowSelected_multiple.png with a 1.79% screenshot diff |
| 2 | try-fix | Compare visible holders against a selected-position set in MarkPlatformSelection, avoiding GetItem(position), and refresh stale Android _multiple/_none baselines |
✅ PASS | 3 files | Robust pass; eliminates the risky lookup entirely and validated the missing baselines |
| 3 | try-fix | Skip header/footer holders in MarkPlatformSelection using holder ItemViewType rather than adapter-position checks |
❌ FAIL | 1 file | Avoided the crash path but still hit the same 1.79% Android _multiple screenshot mismatch |
| 4 | try-fix | Skip only the explicit header/footer endpoint positions using HasHeader/HasFooter bounds, and refresh stale Android _multiple/_none baselines |
✅ PASS | 3 files | Simplest passing variant; very close to the PR direction, but still required baseline updates |
| 5 | try-fix | Centralize safe GetItem() handling in Android item sources and null-check callers, plus refresh stale Android _multiple/_none baselines |
✅ PASS | 7 files | Passed, but broader/riskier than necessary because it changes shared item-source behavior |
| PR | PR #32215 | Skip header/footer adapter positions inside MarkPlatformSelection before calling ItemsSource.GetItem(position) |
❌ FAILED (Gate) | 3 files | Production-code direction is reasonable, but the PR did not achieve a clean Android pass as submitted because the remaining Android baselines were not brought in sync |
Cross-Pollination
| Model | Round | New Ideas? | Details |
|---|---|---|---|
| claude-opus-4.6 | 2 | No | NO NEW IDEAS |
| claude-sonnet-4.6 | 2 | No | NO NEW IDEAS |
| gpt-5.3-codex | 2 | No | NO NEW IDEAS |
| gemini-3-pro-preview | 2 | Yes | NEW IDEA: centralize header/footer safety inside the Android GetItem() implementations rather than guarding each call site |
| claude-opus-4.6 | 3 | No | NO NEW IDEAS |
| claude-sonnet-4.6 | 3 | No | NO NEW IDEAS |
| gpt-5.3-codex | 3 | No | NO NEW IDEAS |
| gemini-3-pro-preview | 3 | No | NO NEW IDEAS |
Exhausted: Yes
Selected Fix: Candidate #4 — It is the simplest passing solution, stays narrowly scoped to the selection-sync bug, and the main actionable gap versus the PR is the same one exposed across attempts: the Android _multiple and _none baselines must be refreshed to match the updated Issue21375 HostApp page.
📋 Report — Final Recommendation
Gate Result: ❌ FAILED
Platform: android
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ❌
Notes
- The verification established a broken baseline without the fix:
Issue21375fails because the app crashes during the selection flow, matching the reported Android CollectionView regression. - With the PR fix applied, the crash no longer appears to be the blocking symptom, but the verification still fails because the screenshot baseline for
SelectedItemsShowSelected_multiple.pngdiffers by 1.79%. - The verification also reported an Android deployment instability (
Broken pipe (32)during package install) on the second pass, so the environment may be contributing noise, but Gate remains failed because the test suite did not cleanly pass with the fix.
⚠️ Final Recommendation: REQUEST CHANGES
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Android CollectionView regression and intended Issue21375 validation surface documented |
| Gate | ❌ FAILED | Android full verification failed to produce a clean pass with the PR applied |
| Try-Fix | ✅ COMPLETE | 5 attempts, 3 passing; passing candidates all required refreshed Android baselines |
| Report | ✅ COMPLETE |
Summary
The PR is close, but I do not recommend approval yet. The runtime guard added in SelectableItemsViewAdapter is directionally correct, however the PR did not land a clean Android validation pass as submitted.
The strongest pattern from try-fix is that multiple alternative runtime fixes successfully eliminate the header/footer crash, but every passing candidate also needed the Android _multiple and _none snapshots refreshed after Issue21375.xaml was updated to include header/footer templates. The PR only refreshed _single, so the test surface and baselines are still out of sync.
Root Cause
There are two coupled problems:
- Production bug: Android selection sync reaches
ItemsSource.GetItem(position)for header/footer adapter positions, which are not real data items and can trigger invalid indexing during selection updates. - Test asset gap: Updating
Issue21375.xamlto add header/footer templates changed the Android visual output, but the PR refreshed onlySelectedItemsShowSelected_single.png. The_multipleand_nonebaselines remained stale, so Android UI verification still fails even when the crash path is fixed.
Fix Quality
The PR's production-code change is reasonable and aligned with the bug mechanism, but the overall PR is incomplete because the Android snapshot set was not fully updated to match the new test page. Among the validated alternatives, Candidate #4 was the simplest passing fix, and Candidate #2 was the most robust; both reinforce the same review outcome: the PR needs additional changes before it should be approved.
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
This is a wrong approach to fix this bug |


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!
Description of Change
Adjusted SelectableItemsViewAdapter to correctly handle selection when header or footer templates are present. Updated Issue21375 test case to include header and footer templates.
Issues Fixed
Fixes #32212
Regressing PR #29818