Skip to content

[Android] Fixed selection logic with header/footer in CollectionView#32215

Closed
kubaflo wants to merge 2 commits intodotnet:mainfrom
kubaflo:fix-32212
Closed

[Android] Fixed selection logic with header/footer in CollectionView#32215
kubaflo wants to merge 2 commits intodotnet:mainfrom
kubaflo:fix-32212

Conversation

@kubaflo
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo commented Oct 26, 2025

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

Copilot AI review requested due to automatic review settings October 26, 2025 13:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 WebResourceRequested event to BlazorWebView for 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;

@kubaflo kubaflo changed the title Fix 32212 [Android] Fixed selection logic with header/footer in CollectionView Oct 26, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 26, 2025
@kubaflo kubaflo changed the base branch from main to net10.0 October 26, 2025 13:48
@kubaflo kubaflo self-assigned this Oct 26, 2025
@kubaflo kubaflo added platform/android area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Oct 26, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

This is the tests validating the fix?

@rmarinho
Copy link
Copy Markdown
Member

Do we need to update the screenshots ?
SelectedItemsShowSelected_single

@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Oct 30, 2025

This is the tests validating the fix?

Exactly, it is

@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Oct 30, 2025

Do we need to update the screenshots ? SelectedItemsShowSelected_single

Yes, thanks! Updated

@kubaflo kubaflo changed the base branch from net10.0 to main October 30, 2025 23:35
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Nov 2, 2025

/rebase

@michelmoorlag
Copy link
Copy Markdown

I would like to test the artifact from this pr but some checks are 'Waiting for status to be reported'.
How to proceed?

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

/rebase

@davishoang96
Copy link
Copy Markdown

Our company app cannot upgrade to .NET 10 because of this bug. We urgently need this PR to be merged. Thank you.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

🚀 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 -- 32215

Or

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

@kubaflo kubaflo changed the base branch from main to inflight/current March 17, 2026 23:31
@kubaflo kubaflo changed the base branch from inflight/current to main March 17, 2026 23:31
@kubaflo kubaflo changed the base branch from main to inflight/current March 17, 2026 23:32
@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Mar 18, 2026

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

kubaflo added 2 commits March 18, 2026 17:16
Adjusted SelectableItemsViewAdapter to correctly handle selection when header or footer templates are present. Updated Issue21375 test case to include header and footer templates.
@kubaflo kubaflo changed the base branch from inflight/current to main March 18, 2026 16:16
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 19, 2026

🤖 AI Summary

📊 Expand Full Review12ce70b · Update SelectedItemsShowSelected_single.png
🔍 Pre-Flight — Context & Validation

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 ArgumentOutOfRangeException when selecting a CollectionView item with a FooterTemplate; a later issue comment confirms the same failure with a HeaderTemplate on .NET 10.
  • The PR changes one Android handler file, updates Issue21375.xaml to include both header and footer templates, and refreshes the Android screenshot artifact for that existing UI test.
  • PR discussion confirms Issue21375 is the intended validation test, and no prior agent review output was found in PR comments.
  • Changed-file classification: implementation = src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs; test surfaces = src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml, src/Controls/tests/TestCases.Android.Tests/snapshots/android/SelectedItemsShowSelected_single.png.

Edge Cases Noted

  • FooterTemplate selection crash from the original issue reproduction.
  • HeaderTemplate exhibits the same failure pattern according to issue comment follow-up.
  • Existing UI test also exercises switching between single, multiple, and none selection modes.

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

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 ArgumentOutOfRangeException when selecting a CollectionView item while a header/footer template is present; a later issue comment confirms the same failure pattern with HeaderTemplate on .NET 10.
  • The PR modifies src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs and extends the existing Issue21375 HostApp 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 Issue21375 is 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, and None selection 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: Issue21375 fails 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.png differs 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 Issue21375 test 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 _multiple and _none baselines 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: Issue21375 fails 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.png differs 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: Issue21375 fails 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.png differs 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:

  1. 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.
  2. Test asset gap: Updating Issue21375.xaml to add header/footer templates changed the Android visual output, but the PR refreshed only SelectedItemsShowSelected_single.png. The _multiple and _none baselines 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.


@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) labels Mar 19, 2026
@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Mar 19, 2026

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kubaflo
Copy link
Copy Markdown
Contributor Author

kubaflo commented Mar 20, 2026

This is a wrong approach to fix this bug

@kubaflo kubaflo closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution platform/android 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android][.NET9] Selecting error when there is a FooterTemplate

8 participants