Skip to content
15 changes: 6 additions & 9 deletions src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Globalization;
using CommunityToolkit.Maui.Converters;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Extensions;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
using Microsoft.Maui.Controls.Shapes;
Expand Down Expand Up @@ -43,11 +44,6 @@ public PopupPage(Popup popup, IPopupOptions popupOptions)
// Only set the content if the parent constructor hasn't set the content already; don't override content if it already exists
base.Content ??= new PopupPageLayout(popup, popupOptions);

if (Shell.Current is Shell shell)
{
Shell.SetPresentationMode(shell, PresentationMode.ModalNotAnimated);
}

tapOutsideOfPopupCommand = new Command(async () =>
{
popupOptions.OnTappingOutsideOfPopup?.Invoke();
Expand Down Expand Up @@ -108,15 +104,16 @@ public async Task CloseAsync(PopupResult result, CancellationToken token = defau

popupClosedEventManager.HandleEvent(this, result, nameof(PopupClosed));
}

// Prevent the Android Back Button from dismissing the Popup if CanBeDismissedByTappingOutsideOfPopup is true

protected override bool OnBackButtonPressed()
{
// Only close the Popup if PopupOptions.CanBeDismissedByTappingOutsideOfPopup is true
if (popupOptions.CanBeDismissedByTappingOutsideOfPopup)
{
return base.OnBackButtonPressed();
CloseAsync(new PopupResult(true), CancellationToken.None).SafeFireAndForget();
}


// Always return true to let the Android Operating System know that we are manually handling the Navigation request from the Android Back Button
return true;
}

Expand Down
Loading