Skip to content

Conversation

@NanthiniMahalingam
Copy link
Contributor

Issue detail

When selecting an item in a grouped CollectionView, the highlight jumps to the first item in the group instead of staying on the selected item.

Root cause

Selected item index value is zero When select the item on the grouped item collection. Always return the zeroth index of the grouped items.

Description of changes

Increment the index value by one while iterating the items in grouped items and return the correct index value if selected item inside the grouped items. If selected item is not contained in the grouped items return -1 as the index value.

Issues Fixed

Fixes #22320

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output:

iOS platform

Before After
22320_iOS_before.mp4
22320_iOS_After.mp4

macOS platform

Before After
22320_mac_before.mov
22320_mac_after.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Apr 22, 2025
@vishnumenon2684 vishnumenon2684 added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 22, 2025
@NanthiniMahalingam NanthiniMahalingam marked this pull request as ready for review April 22, 2025 11:02
Copilot AI review requested due to automatic review settings April 22, 2025 11:02
@NanthiniMahalingam NanthiniMahalingam requested a review from a team as a code owner April 22, 2025 11:02
Copy link
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 fixes the CollectionView grouped item highlighting issue on selection by correcting the index calculation for grouped items. The changes include new test cases in both HostApp and Shared.Tests to validate the fix, and a code fix in the iOS handler to return the correct index.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22320.cs Added automated test case for the highlighting issue
src/Controls/tests/TestCases.HostApp/Issues/Issue22320.cs Implemented UI for manual testing of the fix
src/Controls/src/Core/Handlers/Items/iOS/ObservableGroupedSource.cs Fixed index incrementation to correctly calculate the selected grouped item index
Comments suppressed due to low confidence (1)

src/Controls/src/Core/Handlers/Items/iOS/ObservableGroupedSource.cs:382

  • The increment of 'index' on this line fixes the off-by-one error; please verify that this change correctly updates the index for all group items, avoiding any edge-case issues.
index++;

@rmarinho rmarinho moved this from Todo to Approved in MAUI SDK Ongoing Apr 23, 2025
@rmarinho rmarinho added this to the .NET 9 SR7 milestone Apr 23, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current April 23, 2025 18:10
@PureWeen PureWeen merged commit 42aa3d2 into dotnet:inflight/current Apr 23, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Apr 23, 2025
github-actions bot pushed a commit that referenced this pull request Apr 28, 2025
…#29122)

* Fixed the collection view highlighting issue

* Remove unwanted code section

* Added UI test case.

* Updated the fix and added output images
PureWeen pushed a commit that referenced this pull request May 2, 2025
…#29122)

* Fixed the collection view highlighting issue

* Remove unwanted code section

* Added UI test case.

* Updated the fix and added output images
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request May 9, 2025
…dotnet#29122)

* Fixed the collection view highlighting issue

* Remove unwanted code section

* Added UI test case.

* Updated the fix and added output images
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Maui Grouped CollectionView incorrect item highlighted

4 participants