Skip to content

CollectionView not being able to remove selected item highlight on iOS #30363

@beeradmoore

Description

@beeradmoore

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

  1. Run reproduction project on iOS
  2. Click a row, see it goes red
  3. It stays red when it should go back to the unselected colour
  4. Run the project on Android
  5. Click a row, see that it does not go red
  6. 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.

Relevant log output

Metadata

Metadata

Labels

area-controls-collectionviewCollectionView, CarouselView, IndicatorViewcollectionview-cv2i/regressionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/iosregressed-in-9.0.40s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions