Skip to content

Commit

Permalink
Fix missing iOS navigation events and removes duplicate page (dis)app…
Browse files Browse the repository at this point in the history
…earing events
  • Loading branch information
albyrock87 committed Feb 27, 2025
1 parent e25f0f7 commit e7f3b63
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Sentry.Maui/Internal/MauiEventsBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ public void HandleApplicationEvents(Application application, bool bind = true)
{
if (bind)
{
// Attach element events to all descendents as they are added to the application.
// Attach element events to all existing descendants.
foreach (var descendant in application.GetVisualTreeDescendants().Skip(1))
{
if (descendant is VisualElement element)
{
OnApplicationOnDescendantAdded(application, new ElementEventArgs(element));
}
}

// Attach element events to all descendants as they are added to the application.
application.DescendantAdded += OnApplicationOnDescendantAdded;
application.DescendantRemoved += OnApplicationOnDescendantRemoved;

Expand All @@ -45,8 +54,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
}

// Navigation events
application.PageAppearing += OnApplicationOnPageAppearing;
application.PageDisappearing += OnApplicationOnPageDisappearing;
application.ModalPushed += OnApplicationOnModalPushed;
application.ModalPopped += OnApplicationOnModalPopped;

Expand All @@ -62,8 +69,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
HandleElementEvents(application, bind: false);

// Navigation events
application.PageAppearing -= OnApplicationOnPageAppearing;
application.PageDisappearing -= OnApplicationOnPageDisappearing;
application.ModalPushed -= OnApplicationOnModalPushed;
application.ModalPopped -= OnApplicationOnModalPopped;

Expand Down

0 comments on commit e7f3b63

Please sign in to comment.