-
Notifications
You must be signed in to change notification settings - Fork 492
[BUG] TouchBehaviour in CollectionView2 stops working after Push/Pop of page #2776
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
User can tap row to go to new page, navigate back and tap on new row.
Expected Behavior
User can tap row to go to new page, navigate back and now most of the rows no longer work.
Steps To Reproduce
- Open and run the solution on iOS (tested in simulator)
- Click "ShortList Item 1", "ShortList Item 2", "ShortList Item 3" to see how navigation should work.
- Tap "Toggle Short/Long List" button to change to change to swap the list source to another list (in our production app, this is training events on different months so the list will grow/shrink)
- Tap "LongList Item 1", "LongList Item 2", "LongList Item 3", "LongList Item 4", "LongList Item 5" and view animation of row tapped and if a page is pushed or not
- At first glance three of these work (maybe related to there being three "ShortList Item"?)
- After tapping to try use all of them a second time it appears now only two work.
- Continuing to tap you will see console output, this is provided by the custom
GridTestBehaviorthat is in the project, indicating that behviors themselves are not broken, just TouchBehavior.
Link to public reproduction project repository
https://github.com/beeradmoore/maui-issue-CollectionViewTouchEffect
Environment
- .NET MAUI CommunityToolkit: 12.0
- OS: macOS 15.5, tested on iOS Simulator 18.4
- .NET MAUI: 9.0.80Anything else?
The issue still exists rolling back to CommunityToolkit.Maui v11.2.
This project is using CollectionViewHandler2 (see here). If we use use the out of the box CollectionView the issue does not occur. I believe this is a CommunityToolkit.Maui issue though as it impacts TouchBehavior but not all other behaviors.
Issue does not impact Android (because CollectionViewHandler2 is not used there I guess).
These rows also have GridTestBehavior added. It simply adds a TapGestureRecognizer and will output the label of the row tapped. When you tap on a row while it is in its "broken" state this other behavior will continue to fire, further leading me to believe the issue is in TouchBehavior itself.
It does not matter if the page is Push/Pop or PushModal/PopModal. See RowClicked in MainPageModel.cs and GoBackAsync in OtherPageModel.cs to easily change this behavior between the two. However if you never Push to the next page the issue does not happen. At one point I was using ObservableCollection and I would clear/add new rows to test row recycling. Adding a total of 1000 new items over 100 list reloads the issue did not appear if we never navigated to the new page and back (eg. Disable the push so you can still view the animation).
Using CollectionViews SelectedItem is not an option as we want multiple places on the row the user can tap. Using raw TapGestureRecognizer instead of TouchBehavior works, but we are using TouchBehavior due to getting touch indicators.
(Repo and project is also mis-labeled TouchEffect, because I am migrating code from XF with TouchEffect to MAUI with TouchBehavior and I wrote it wrong. It has been a week...)