From 80cd6632bd7ea8b6d3cb4a0e76c4fc3aab3bc3bb Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 25 Apr 2019 23:10:46 +0100 Subject: [PATCH] close menu if the toplevel menu item is clicked and its already opened. makes behavior consistent with wpf. --- .../Platform/DefaultMenuInteractionHandler.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs b/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs index 942104d61b..0badd918cc 100644 --- a/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs +++ b/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs @@ -336,7 +336,18 @@ namespace Avalonia.Controls.Platform if (e.MouseButton == MouseButton.Left && item?.HasSubMenu == true) { - Open(item, false); + if (item.IsSubMenuOpen) + { + if (item.Parent is Menu) + { + CloseMenu(item); + } + } + else + { + Open(item, false); + } + e.Handled = true; } }