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
21.86k stars 1.68k forks source link

[Android] Disabled Picker view intercepts GestureRecognizer of parent container #22565

Open etadzeta opened 1 month ago

etadzeta commented 1 month ago

Description

For some reason if I have a disabled Picker inside a Grid I cannot use GestureRecognizer attached to Grid (parent container) with Android, it does not fire if I click directly on Picker, so I assume it intercepts with Picker built-in click listener. In attached screenshot I painted Grid to Red color, and Picker to Gray, and GestureRecognizer is only hit if I click on a Red area. android In this example the Grid's GestureRecognizer points to existing method to update the counter and text on the button.

The expected behaviour in short - I should see updated text on a button whenever I click Red or Gray area (parent Grid or Picker view itself), however it does not work on Android. I can trigger GestureRecognizer attached method only if I click directly on Grid (Red area). Everything works as expected on iOS, the button is updated if I click on any area (Grid or Picker)

Steps to Reproduce

  1. Create a File > New .NET MAUI App
  2. Open MainPage.xaml and add a grid with disabled picker before Button from initial template. Add a GestureRecognizer to Grid poiniting to existing method OnCounterClicked. The file will look like

    <?xml version="1.0" encoding="utf-8"?>
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">
    <ScrollView>
        <VerticalStackLayout Padding="30,0"
                             Spacing="25">
            <Image Source="dotnet_bot.png"
                   HeightRequest="185"
                   Aspect="AspectFit"
                   SemanticProperties.Description="dot net bot in a race car number eight" />
            <Label Text="Hello, World!"
                   Style="{StaticResource Headline}"
                   SemanticProperties.HeadingLevel="Level1" />
            <Label Text="Welcome to &#xA;.NET Multi-platform App UI"
                   Style="{StaticResource SubHeadline}"
                   SemanticProperties.HeadingLevel="Level2"
                   SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
    
            <Grid Padding="20"
                  BackgroundColor="DarkRed"
                  HorizontalOptions="FillAndExpand"
                  VerticalOptions="FillAndExpand">
                <Picker BackgroundColor="Gray"
                        IsEnabled="False"
                        VerticalOptions="CenterAndExpand" />
                <Grid.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnCounterClicked" />
                </Grid.GestureRecognizers>
            </Grid>
    
            <Button x:Name="CounterBtn"
                    Text="Click me"
                    SemanticProperties.Hint="Counts the number of times you click"
                    Clicked="OnCounterClicked"
                    HorizontalOptions="Fill" />
        </VerticalStackLayout>
    </ScrollView>
    </ContentPage>

    3) Click on Picker (Gray area), expected result - button's text is changed with updated counter value.

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

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 API 34

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

jaosnz-rep commented 1 month ago

Can repro this issue at Android platform on the latest 17.11 Preview 1(8.0.40/8.0.21/8.0.3), and works fine on Windows platform.

PureWeen commented 1 month ago

@etadzeta if you set InputTransparent to true on the Picker does that let the gesture propagate to the grid?

etadzeta commented 1 month ago

@PureWeen thanks for the comment, I've tried it and yes it indeed works as expected for disabled Picker. However if I don't set this InputTransparent parameter to true I have correct and expected behaviour in iOS. I still think this is an issue, because in Xamarin such control worked correctly with same settings on both platforms. For now I'll use this parameter as a workaround, thanks