dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22k stars 1.72k forks source link

SwipeView in CollectionView misses binding when deleting an item after swiping open multiple items #21958

Open Equabyte opened 5 months ago

Equabyte commented 5 months ago

Description

SwipeView is typically used inside a CollectionView to provide an option to delete a collection view item (e.g. by revealing a trash can icon swipe item and using Command binding to remove the corresponding item when clicked). When multiple items of the collection view are swipe open, deleting any of the swiped items different from the bottom one causes a refresh of the CollectionView with unexpected side effects: this refresh is not supposed to alter in any way the SwipeView open state of the other collection view items (which should stay open), but in fact the SwipeView of all items following the deleted one is getting closed. Deleting further items later on will present other erratic behavior like e.g. some SwipeViews will show open again but on unexpected CollectionView items.

Steps to Reproduce

  1. Create a MAUI project with one page where a CollectionView embeds a SwipeView that can be used to delete any of its items through an appropriately bound custom Command;
  2. populate the CollectionView with, say, 10 items; run the app on Android and swipe open three or more of the CollectionView items, revealing the deletion option of your SwipeView;
  3. delete the top item or any of the middle items for which you opened the SwipeView and observe the behavior.

Desired result: every time you delete an item by clicking the SwipeView "delete" option, the corresponding item should be removed from the CollectionView, the CollectionView should be refreshed and all other open SwipeViews should stay open.

Error result: the SwipeView of the CollectionView items following the deleted item is getting closed.

Link to public reproduction project repository

https://github.com/Equabyte/MAUI_SwipeView_Error

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14 (SDK34)

Did you find any workaround?

Not yet.

Relevant log output

No response

Equabyte commented 4 months ago

Short video showing the issue on production app: https://github.com/dotnet/maui/assets/145383043/d91616fe-364c-497a-99c5-3bf891f8093a

Equabyte commented 4 months ago

Added link to repro project. https://github.com/Equabyte/MAUI_SwipeView_Error

kevinxufei commented 4 months ago

Verified this issue with Visual Studio 17.10.0 Preview 5 (8.0.14/8.0.21). Can repro it on android platform.

Equabyte commented 3 months ago

Any chance to include in SR7 ?