CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.27k stars 401 forks source link

[BUG] ANDROID: buttons in Expander can't be clicked #1216

Closed glenn2223 closed 1 year ago

glenn2223 commented 1 year ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

After expanding the Expander, none of the buttons inside work - they should trigger a toast.

Windows works as expected

Expected Behavior

The click events to trigger

Steps To Reproduce

  1. Run the project on an Android device/emulator
  2. Expand the expander at the bottom
  3. Try to click on either button and no toast is fired

Link to public reproduction project repository

https://github.com/glenn2223/Community-Toolkit-Mail-Android-Expander-Issue

Environment

- .NET MAUI CommunityToolkit: 5.2.0
- OS: Windows10 (issue produced on physical and emulated Android device)
- .NET MAUI: 7 & 8-preview

Anything else?

Sorry for the shoddy code 😁

brminnick commented 1 year ago

I've confirmed this is not a bug in Expander.

The issue is that you've aded a GestureRecognizer to your Button which is overriding the Clicked action:

  <Button x:Name="AddButton"
          Clicked="AddClicked"
          Text="Add"
          HorizontalOptions="Start"
          VerticalOptions="End"
          WidthRequest="100">
      <Button.GestureRecognizers>
          <PointerGestureRecognizer PointerEntered="PointerGestureRecognizer_PointerEntered" />
      </Button.GestureRecognizers>
  </Button>

When you remove the GestureRecognizer, the Clicked event fires:

  <Button x:Name="AddButton"
          Clicked="AddClicked"
          Text="Add"
          HorizontalOptions="Start"
          VerticalOptions="End"
          WidthRequest="100">
  </Button>

I do not know if this behavior is intended by the .NET MAUI engineering team. I recommend opening this Issue on the .NET MAUI GitHub Repo.

glenn2223 commented 1 year ago

Ahh, I see. For some reason I thought I already had the gesture recogniser in place this when I switched from a horizontal stack to an expander - sorry about that.

Thanks for checking on this for me