Closed kaushik-sarker closed 3 months ago
Thanks @kaushik-sarker for creating this issue, after reviewing this issue in-depth I found the following:
I can confirm that if you try to show up the popup and then close it before 300ms, it won't close. However, the Popup has the following event that is triggered once the UI is fully loaded:
void Spinner_Opened(object? sender, CommunityToolkit.Maui.Core.PopupOpenedEventArgs e)
{
Console.WriteLine("Popup Openned.");
((SpinnerPopup)sender).Close();
Console.WriteLine("Popup Closed.");
}
On your sample, the popup won't be able to be closed, because the UI has not been initialized for instance it cannot close something that hasn't loaded visually speaking.
If by adding the Task.Delay(300) does not work for your scenario, I have a few recommendations that could work:
I don't think this is an issue of the Popup itself but rather than the native platform itself, and what it takes the time to process the UI and hide it.
I'm closing this issue, however, if none of the recommendations mentioned above work for you, we can discuss it on a discussion topic, and generate ideas to solve it.
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
If the interval between the popup show and the close method call is less than 300 ms, the close() call fails to close the spinner popup. Why do I want something like that? I am making a network request in the OnAppearing() method, and I want to display a loading spinner while making the request (please ignore the visual effect on the user). The network request might be resolved very quickly. I noticed that if the interval between Show and Close is very minimal, the popup is not closing, and this happens only inside the OnAppearing overridden method.
Expected Behavior
The popup should be shown and closed properly.
Steps To Reproduce
Please look into the OnAppearing() method inside MainPage.xaml.cs
Link to public reproduction project repository
https://github.com/kaushik-sarker/PopupIssueDemo
Environment
Anything else?
No response