-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
A common (the most common?) scenario for CollectionView is to have a list of items. Clicking an item will do some action (navigate, show dialog, etc). Ideally there is an animation that appears to indicate that you have touched a row, and then that animation disappears. In the past (XF) we would set the SelectedItem of the CollectionView to null when it was set. However this is not working currently.
When setting SelectedItem back to null the item is staying selected on iOS. On Android the item selected state is not showing. It does not appear that there is a good way to get a row touch animation with out of the box CollectionView.
A way I did try to achieve this was with CommunityToolkit.Maui and its TouchBehavior, however that lead to another bug of TouchBehaviour in CollectionView2 stops working after Push/Pop of page.
I am unsure if there is a possible way to achieve this at all. Considering how important CollectionViews are, both of these bugs are degrading the visual impact of apps using MAUI.
This problem impacts both out of the box CollectionView and those using CollectionViewHandler2.
This problem persists if you use bind to SelectedItem (see MainPage.xml and MainPageModel.cs) instead of the SelectionChanged event.
Adding a await Task.Delay between getting the selection and setting the selection to null will give the correct behavior. However this delays everything else you want to do. Also because you are taking a guess at the duration to wait it may not work for all scenarios.
Steps to Reproduce
- Run reproduction project on iOS
- Click a row, see it goes red
- It stays red when it should go back to the unselected colour
- Run the project on Android
- Click a row, see that it does not go red
- It should go red and then go back to the unselected colour
Both projects are doing different behaviors.
Link to public reproduction project repository
https://github.com/beeradmoore/maui-issue-CollectionViewSelectedItemBug
Version with bug
9.0.81 SR8.1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android
Affected platform versions
iOS 18.5, Android 15
Did you find any workaround?
Only current workaround is to not use any animations on selecting rows in a CollectionView.