Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where BaseContextFlyout was not closed after selecting an item #11245

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FrameworkElement>().ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width
secondaryElements.ForEach(i => BaseContextMenuFlyout.SecondaryCommands.Add(i));
Expand Down Expand Up @@ -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<FrameworkElement>().ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width
secondaryElements.ForEach(i => ItemContextMenuFlyout.SecondaryCommands.Add(i));
Expand All @@ -605,10 +605,10 @@ private async Task LoadMenuItemsAsync()
}
}

private void AddCloseHandler(IList<ICommandBarElement> primaryElements, IList<ICommandBarElement> secondaryElements)
private void AddCloseHandler(CommandBarFlyout flyout, IList<ICommandBarElement> primaryElements, IList<ICommandBarElement> secondaryElements)
{
// Workaround for WinUI (#5508)
var closeHandler = new RoutedEventHandler((s, e) => ItemContextMenuFlyout.Hide());
var closeHandler = new RoutedEventHandler((s, e) => flyout.Hide());

primaryElements
.OfType<AppBarButton>()
Expand Down