Skip to content

Commit

Permalink
Merge pull request #115 from troy-ob/remove_DescendantRemoved_to_fix_…
Browse files Browse the repository at this point in the history
…issue_97

Fix: Exception "MauiContext should have been set on parent" when removing a child from its parent layout on iOS
  • Loading branch information
LuckyDucko authored Sep 15, 2024
2 parents 6e556f4 + 95791d1 commit 86c6590
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public Task AddAsync(PopupPage page)
{
page.Parent ??= Application.Current?.MainPage;

page.DescendantRemoved += HandleChildRemoved;

var keyWindow = GetKeyWindow(UIApplication.SharedApplication);
if (keyWindow?.WindowLevel == UIWindowLevel.Normal)
keyWindow.WindowLevel = -1;
Expand Down Expand Up @@ -82,8 +80,6 @@ public async Task RemoveAsync(PopupPage page)

await Task.Delay(50);

page.DescendantRemoved -= HandleChildRemoved;

if (handler != null && viewController != null && !viewController.IsBeingDismissed)
{
var window = viewController.View?.Window;
Expand Down Expand Up @@ -134,11 +130,4 @@ private static void DisposeModelAndChildrenHandlers(VisualElement view)
(view?.Handler?.PlatformView as UIView)?.RemoveFromSuperview();
(view?.Handler?.PlatformView as UIView)?.Dispose();
}

private void HandleChildRemoved(object sender, ElementEventArgs e)
{
var view = e.Element;
DisposeModelAndChildrenHandlers((VisualElement)view);
}

}

0 comments on commit 86c6590

Please sign in to comment.