Maui
Maui copied to clipboard
[BUG][Regression][8.0.1] TouchBevavior binding not working in a CollectionView
Is there an existing issue for this?
- [X] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [X] 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
TouchBehavior binding is not working in a CollectionView when using 8.0.1. It seems like the wrong item is binded after the CollectionView is scrolled a bit (recycling issue?). This is a regression in 8.0.1. No issue in 8.0.0.
I mentionned this issue in the PR but so far nobody has reacted. https://github.com/CommunityToolkit/Maui/pull/1791#issuecomment-2039825987
Expected Behavior
I expect it to work the same as in 8.0.0.
Steps To Reproduce
- Open and run solution from repro.
- Tap on any item. Scroll the CollectionView. Tap again any item.
- At some point (probably after recycling of views), the alert shows that the TouchBehavior binds to the wrong item.
Link to public reproduction project repository
https://github.com/tranb3r/Issues/tree/main/MauiAppMct801TouchBehavior
Environment
- .NET MAUI CommunityToolkit:8.0.1
- OS:Android
- .NET MAUI:8.0.14
+1, not working with Collection View data template.
@tranb3r thanks for you repo. Friendly asking, when provide a repo, please make sure it has all platforms on it, that way we can test it better <3
My TouchBehavior in a CollectionView Data template doesn't seem to be performing any animations either.
<DataTemplate x:Key="CustomModeTemplate">
<components:ShadowFrame x:DataType="models:CustomModeCollectionItem"
Padding="0"
x:Name="Element"
AutomationId="{Binding Title}"
Grid.Row="{Binding GridRow}"
Grid.Column="{Binding GridColumn}"
HeightRequest="{Binding Source={x:Reference Element}, Path=Width}">
<components:ShadowFrame.Behaviors>
<mct:TouchBehavior DefaultAnimationDuration="250"
DefaultAnimationEasing="{x:Static Easing.SpringOut}"
PressedScale=".95"
CommandParameter="{Binding Index}"
Command="{Binding TappedCommand, Source={x:Reference ThisView}}" />
...
For example the shadowFrame in the example above does not change its scale.
Note this is only on Android. It works fine on iOS.
Toolkit version 8.0.1
@Hackmodford this is another problem, please open a new issue with a sample project that reproduce the bug
Any update?
@jfversluis 8.0.0 was released a month ago, immediately hot-fixed with 8.0.1 which introduced this regression, and now there is a new major release 9.0.0, but still without a fix for this regression. Is there any good reason to keep the hot-fix introduced in 8.0.1? If it cannot be fixed, why not simply rollback it?
8.0.1 didn't just introduce a regression, it fixed a very important thing as well, which might have this side-effect. I'm sorry you're experiencing that, but the fix in 8.0.1 is too important to roll back. Most notably, its a breaking change to, so rolling it back and reintroducing it later will cause a lot of frustration with our users.
If there is nothing that you need in 8.0.1 and 9.0.0, you can stick to 8.0.0 for now until we get this issue resolved.
I thought the idea in 8.0.1 was to automatically set the bindingcontext to behaviors, which is something convenient but not absolutely mandatory. Maybe I misunderstood something. I'll stick to 8.0.0 for now. Thanks.
@brminnick is probably the one you want to talk to. Maybe for a more direct discussion you can join the Discord server to discuss details.
Any workarounds? I'm trying to get rid of my custom port of Maui.TouchEffect in favor of this but having problems...
@phunkeler
This is my current workaround. Just add a TapGestureRecognizer with the command instead of using the TouchBehavior.
<!-- There is currently a bug in the touch behavior that causes commands to not be bound correctly in Android. Community Tooklit version 8.0.1 -->
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Command}"/>
</Border.GestureRecognizers>
<Border.Behaviors>
<mct:TouchBehavior DefaultAnimationDuration="250"
DefaultAnimationEasing="{x:Static Easing.SpringOut}"
PressedScale=".95" />
</Border.Behaviors>
```
@phunkeler
This is my current workaround. Just add a
TapGestureRecognizerwith the command instead of using the TouchBehavior.<!-- There is currently a bug in the touch behavior that causes commands to not be bound correctly in Android. Community Tooklit version 8.0.1 --> <Border.GestureRecognizers> <TapGestureRecognizer Command="{Binding Command}"/> </Border.GestureRecognizers> <Border.Behaviors> <mct:TouchBehavior DefaultAnimationDuration="250" DefaultAnimationEasing="{x:Static Easing.SpringOut}" PressedScale=".95" /> </Border.Behaviors> ```
Sure, but this only works for a simple Tap, not for other gestures like LongPress, which is the reason why we're using TouchBehavior.
@jfversluis I wonder if this is somehow related to this MAUI issue . I see the same issue for both TapGestures as well as the TouchBehavior and also on iOS.
Any update?
We plan on fixing this with a breaking change when we do a major-version bump to .NET 9