[BUG] Popup is not closed by calling Close or CloseAsync method.
cat0363 opened this issue · 1 comments
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
Calling the Close, CloseAsync method of the Popup class no longer closes the Popup.
This issue is caused by a fix in PR #2166.
This is caused by the code I added below.
[src\CommunityToolkit.Maui\HandlerImplementation\Popup\Popup.shared.cs]
public static CommandMapper<IPopup, PopupHandler> ControlPopUpCommandMapper = new(PopupHandler.PopUpCommandMapper)
{
#if IOS || MACCATALYST
[nameof(IPopup.OnOpened)] = MapOnOpened,
[nameof(IPopup.OnClosed)] = MapOnClosed
#endif
};
The above code will no longer call the following method.
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopupHandler.macios.cs]
public static async void MapOnClosed(PopupHandler handler, IPopup view, object? result)
{
var presentationController = handler.PlatformView.PresentationController;
if (presentationController?.PresentedViewController is UIViewController presentationViewController)
{
await presentationViewController.DismissViewControllerAsync(true);
}
view.HandlerCompleteTCS.TrySetResult();
handler.DisconnectHandler(handler.PlatformView);
}
Since the above method is no longer called, the Popup will continue to wait.
Expected Behavior
The Popup must be closed when the Close or CloseAsync method is called.
Steps To Reproduce
Change the library reference of the Community Toolkit in the reproduction project to the latest one in main and perform the following steps.
- Press the Close Test or CloseAsync Test button.
- Press the Close button in the displayed Popup.
Popup does not close at step 2.
Link to public reproduction project repository
https://github.com/cat0363/MauiComm-IssuePopupCloseMethod.git
Environment
- .NET MAUI CommunityToolkit: main's latest
- OS: iOS
- .NET MAUI: 8.0.82
Anything else?
No response
Now that I know how to fix it, I will create a PR.