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
22.28k stars 1.76k forks source link

CollectionView's Items Aren't Selected When a Parent Has a TapGestureRecognizer #26182

Open brett-macisaac opened 1 day ago

brett-macisaac commented 1 day ago

Description

When a CollectionView is nested inside a parent that has a TapGestureRecognizer, the CollectionView's items cannot be selected unless the user presses the item for at least a few seconds (even then sometimes it doesn't work). The parent with the TapGestureRecognizer also doesn't have to be a direct parent for the issue to arise, I've just structured the XAML in the MPE this way for simplicity.

The expected behaviour is that the TapGestureRecognizer of the CollectionView's parent shouldn't be called and the CollectionView's items should be selected as intended. This is the behaviour that occurs on Android and is also the behaviour that's observed when a normal Button is clicked on iOS.

Steps to Reproduce

  1. Try to click one of the CollectionView's items (i.e. either 'Hello' or 'World'). You will fine that the container's TapGestureRecognizer is called, but the CollectionView's selection doesn't occur.
  2. Press down on one of the CollectionView's items for a few seconds. You might find that the selection occurs (and that the parent's TapGestureRecognizer isn't called).
  3. Click the "Hello World" button beneath the CollectionView. You should observe that its command is called without issue, which contrasts with the CollectionView's items.
  4. Remove the TapGestureRecognizer from the CollectionView's parent.
  5. Click one of the CollectionView's items again. You should notice that the selection works (without having to press down for a few seconds).

Link to public reproduction project repository

https://github.com/brett-macisaac/maui-clv-selection-bug

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

iOS

Affected platform versions

iOS 17/18

Did you find any workaround?

No response

Relevant log output

similar-issues-ai[bot] commented 1 day ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

Zhanglirong-Winnie commented 19 hours ago

This issue has been verified using Visual Studio 17.13 Preview 1 (9.0.10 & 9.0.0-rc.2.24503.2 & 8.0.100 & 8.0.83). Can repro this issue on iOS platform.