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.29k stars 404 forks source link

[BUG] After increasing Popup height any elements outside of original bounds do not receive touches on iOS #1522

Closed primozcerar closed 8 months ago

primozcerar 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 increasing Popup height any elements outside of original bounds do not receive touches.

Expected Behavior

Touches should be received by any element on the popup even after increasing it's size

Steps To Reproduce

  1. Create a Popup with some resizable layout and a button
  2. Increase the size of the Popup content so that the button stay on the bottom
  3. On iOS it is now impossible to press the button (tested on iOS simulator "iPhone 15 iOS 17" and "iPhone 14 iOS 16"

Link to public reproduction project repository

https://github.com/cat0363/MauiComm-IssuePopupGesture

Environment

- .NET MAUI CommunityToolkit: 6.1.0, same behaviour on 5.0.0
- OS: iOS 17
- .NET MAUI: 7.0.96/7.0.100

Anything else?

No response

ghost commented 1 year ago

Hi @primozcerar. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

primozcerar commented 1 year ago

@bijington I'm sorry I can not currently create a reproduction repo as I am working on a project with an extremely tight deadline. I will get back to it when I can if you can't reproduce it. This is however a serious issue for me right now and I might have to temporarily drop iOS support because of it as I have found no workaround and redesigning the Popup or splitting it into multiple popups would take too much time and look unprofessional.

primozcerar commented 1 year ago

I have just found a workaround that might help with solving this issue or help anyone stuck on this. It is resolved by measuring the Popup.Content size and then assigning it to the content.parent element.

(Dialog.Content!.Parent as VisualElement)!.HeightRequest = measuredSize.Height;

cat0363 commented 1 year ago

Although not Popup, I have experienced a problem similar to this on the .NET MAUI side. I remember implementing workarounds like the one you described.

cat0363 commented 1 year ago

@primozcerar , @bijington , I don't know if this is the same issue, but I reproduced it below.

<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    x:Class="MauiComm_IssuePopupGesture.PopupPage1"
    Size="200,200" HorizontalOptions="Center" VerticalOptions="Center">
    <Grid x:Name="gdTest" RowDefinitions="*,44,44,44" SizeChanged="gdTest_SizeChanged" VerticalOptions="Start" HeightRequest="200">
        <Label Grid.Row="0" Text="This is gesture test." />
        <Label Grid.Row="1" x:Name="lblTapTimes" Text="Tap Times : 0" />
        <Button Grid.Row="2" x:Name="btnChangeSize" Text="Size Change" Clicked="btnChangeSize_Clicked" />
        <Button Grid.Row="3" x:Name="btnClick" Text="Click" Clicked="btnClick_Clicked" />
    </Grid>
</toolkit:Popup>

void btnChangeSize_Clicked(object sender, EventArgs e)
{
    gdTest.HeightRequest = 250;
}

void btnClick_Clicked(object sender, EventArgs e)
{
    lblTapTimes.Text = "Tap Times : " + (++tapTimes);
}

void gdTest_SizeChanged(object sender, EventArgs e)
{
    Size = new Size(Size.Width, gdTest.Height);
    // (Content!.Parent as VisualElement)!.HeightRequest = gdTest.Height;  // <= workaround code
}

Below is the verification video.

https://github.com/CommunityToolkit/Maui/assets/125236133/a665f531-8dc1-4351-b9b6-4ee8a5603e21

Uncommenting the workaround code works as intended.

https://github.com/CommunityToolkit/Maui/assets/125236133/24787e34-53b3-4f0f-9588-4c1b78a0d443

If the problem is the same, it is possible to upload the reproduction code.

primozcerar commented 1 year ago

@cat0363 Thank you very much. That is exactly the issue I am facing.

cat0363 commented 1 year ago

@primozcerar , Thank you for confirmation.

I have uploaded the reproduction code below. https://github.com/cat0363/MauiComm-IssuePopupGesture.git

williambohrmann3 commented 11 months ago

I am running into an issue where the gesture recognizer attached to a Border within a Popup isn't being hit upon a tap/click. This is also on iOS. Here is a reproducer I pushed to GH. Should I open a separate issue, or is this caused by the same bug? This isn't a MAUI bug it seems - when using the same controls inside a ContentPage instead of a Popup, not able to repro.