-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed the CollectionView grouped item highlighting issue on selection #29122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed the CollectionView grouped item highlighting issue on selection #29122
Conversation
There was a problem hiding this 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++;
…#29122) * Fixed the collection view highlighting issue * Remove unwanted code section * Added UI test case. * Updated the fix and added output images
…#29122) * Fixed the collection view highlighting issue * Remove unwanted code section * Added UI test case. * Updated the fix and added output images
…dotnet#29122) * Fixed the collection view highlighting issue * Remove unwanted code section * Added UI test case. * Updated the fix and added output images
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