Browse Source

fix nested popups closing

ahopper 6 years ago
parent
commit
bc8a5af921
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/Avalonia.Controls/Primitives/Popup.cs

+ 8 - 1
src/Avalonia.Controls/Primitives/Popup.cs

@@ -450,7 +450,14 @@ namespace Avalonia.Controls.Primitives
 
         private bool IsChildOrThis(IVisual child)
         {
-            return _popupHost != null && ((IVisual)_popupHost).FindCommonVisualAncestor(child) == _popupHost;
+            IVisual root = child.GetVisualRoot();
+            while (root is IHostedVisualTreeRoot hostedRoot )
+            {
+                if (root == this._popupHost)
+                    return true;
+                root = hostedRoot.Host?.GetVisualRoot();
+            }
+            return false;
         }
         
         public bool IsInsidePopup(IVisual visual)