From 3d5def73713545b8f941cdbdd8e419c647d5c5f2 Mon Sep 17 00:00:00 2001 From: Alberto Aldegheri Date: Thu, 27 Feb 2025 15:53:10 +0100 Subject: [PATCH] Fix missing iOS navigation events and removes duplicate page (dis)appearing events --- src/Sentry.Maui/Internal/MauiEventsBinder.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Sentry.Maui/Internal/MauiEventsBinder.cs b/src/Sentry.Maui/Internal/MauiEventsBinder.cs index 23605ccb2e..471bcb3472 100644 --- a/src/Sentry.Maui/Internal/MauiEventsBinder.cs +++ b/src/Sentry.Maui/Internal/MauiEventsBinder.cs @@ -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;