Fix ContextMenu submenu click bug

This commit is contained in:
chinboy
2025-07-18 14:08:56 +08:00
parent b957381919
commit b69bfb8c3b
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -69,6 +69,7 @@ public class ContextMenu : AvaloniaContextMenu,
_popup.SetIgnoreIsOpenChanged(true);
_popup.IsMotionAwareOpen = true;
};
}
private bool MenuPopupClosePredicate(IPopupHostProvider hostProvider, RawPointerEventArgs args)
@@ -81,6 +82,11 @@ public class ContextMenu : AvaloniaContextMenu,
popupRoots.UnionWith(MenuItem.CollectPopupRoots(childMenuItem));
}
}
if (_popup?.Host is PopupRoot popupRoot)
{
popupRoots.Add(popupRoot);
}
return !popupRoots.Contains(args.Root);
}
+1
View File
@@ -146,6 +146,7 @@ public class MenuItem : AvaloniaMenuItem
private bool MenuPopupClosePredicate(IPopupHostProvider hostProvider, RawPointerEventArgs args)
{
var popupRoots = CollectPopupRoots(this);
return !popupRoots.Contains(args.Root);
}