[Android] Disabled Picker view intercepts GestureRecognizer of parent container
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.
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
- Create a File > New .NET MAUI App
- Open
MainPage.xamland add a grid with disabled picker beforeButtonfrom initial template. Add aGestureRecognizertoGridpoiniting to existing methodOnCounterClicked. 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 
.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>
- 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
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:
- Adding TapGestureRecognizer to Child control restricts touch for Parent control in Android platform (#21180), similarity score: 0.76
- [Bug][Android]The IsEnable property of the Picker does not work (#18035), similarity score: 0.75
Closed similar issues:
- Buttons behind "Pop-Up" are handling taps in Android, which is different than Windows behavior (and Xamarin) (#11663), similarity score: 0.77
- [Android] Tap through grid (#21695), similarity score: 0.75
- [regression/7.0.92] [Android] Grid contents and layout are messed up by Picker changes (#16354), similarity score: 0.75
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
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.
@etadzeta if you set InputTransparent to true on the Picker does that let the gesture propagate to the grid?
@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