Fixed the CollectionView grouped item highlighting issue on selection#29122
Merged
PureWeen merged 4 commits intodotnet:inflight/currentfrom Apr 23, 2025
Merged
Fixed the CollectionView grouped item highlighting issue on selection#29122PureWeen merged 4 commits intodotnet:inflight/currentfrom
PureWeen merged 4 commits intodotnet:inflight/currentfrom
Conversation
Contributor
There was a problem hiding this comment.
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
approved these changes
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Output:
iOS platform
22320_iOS_before.mp4
22320_iOS_After.mp4
macOS platform
22320_mac_before.mov
22320_mac_after.mov