From 81c74dfdb800a174cc56b58c3ca8581f6c4034f2 Mon Sep 17 00:00:00 2001 From: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Date: Sat, 11 Feb 2023 20:40:53 +0900 Subject: [PATCH] Close BaseContextFlyout properly --- src/Files.App/BaseLayout.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Files.App/BaseLayout.cs b/src/Files.App/BaseLayout.cs index 604fda9b7f1e..c70d81030a02 100644 --- a/src/Files.App/BaseLayout.cs +++ b/src/Files.App/BaseLayout.cs @@ -539,7 +539,7 @@ public async void BaseContextFlyout_Opening(object? sender, object e) BaseContextMenuFlyout.PrimaryCommands.Clear(); BaseContextMenuFlyout.SecondaryCommands.Clear(); var (primaryElements, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(items); - AddCloseHandler(primaryElements, secondaryElements); + AddCloseHandler(BaseContextMenuFlyout, primaryElements, secondaryElements); primaryElements.ForEach(i => BaseContextMenuFlyout.PrimaryCommands.Add(i)); secondaryElements.OfType().ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width secondaryElements.ForEach(i => BaseContextMenuFlyout.SecondaryCommands.Add(i)); @@ -589,7 +589,7 @@ private async Task LoadMenuItemsAsync() ItemContextMenuFlyout.PrimaryCommands.Clear(); ItemContextMenuFlyout.SecondaryCommands.Clear(); var (primaryElements, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(items); - AddCloseHandler(primaryElements, secondaryElements); + AddCloseHandler(ItemContextMenuFlyout, primaryElements, secondaryElements); primaryElements.ForEach(i => ItemContextMenuFlyout.PrimaryCommands.Add(i)); secondaryElements.OfType().ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width secondaryElements.ForEach(i => ItemContextMenuFlyout.SecondaryCommands.Add(i)); @@ -605,10 +605,10 @@ private async Task LoadMenuItemsAsync() } } - private void AddCloseHandler(IList primaryElements, IList secondaryElements) + private void AddCloseHandler(CommandBarFlyout flyout, IList primaryElements, IList secondaryElements) { // Workaround for WinUI (#5508) - var closeHandler = new RoutedEventHandler((s, e) => ItemContextMenuFlyout.Hide()); + var closeHandler = new RoutedEventHandler((s, e) => flyout.Hide()); primaryElements .OfType()