From 35cc6ad6d497950d60fbb27c69d4b72d85b8040d Mon Sep 17 00:00:00 2001 From: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:31:00 +0900 Subject: [PATCH] Fix: Fixed issue where the properties window could not be opened on the home page (#14385) --- src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs | 5 +++-- src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs | 7 ++++--- src/Files.App/UserControls/Widgets/HomePageWidget.cs | 2 +- .../UserControls/Widgets/QuickAccessWidget.xaml.cs | 5 +++-- .../UserControls/Widgets/RecentFilesWidget.xaml.cs | 7 ++++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs index c0bdc8d31f53..1bba631fb6e2 100644 --- a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs @@ -298,14 +298,15 @@ private void OpenProperties(DriveCardItem item) if (!HomePageContext.IsAnyItemRightClicked) return; + var flyout = HomePageContext.ItemContextFlyoutMenu; EventHandler flyoutClosed = null!; flyoutClosed = (s, e) => { - HomePageContext.ItemContextFlyoutMenu!.Closed -= flyoutClosed; + flyout!.Closed -= flyoutClosed; FilePropertiesHelpers.OpenPropertiesWindow(item.Item, associatedInstance); }; - HomePageContext.ItemContextFlyoutMenu!.Closed += flyoutClosed; + flyout!.Closed += flyoutClosed; } private async void Button_Click(object sender, RoutedEventArgs e) diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index a17c55ebedd5..0042c7e961b5 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -72,10 +72,11 @@ private void OpenProperties(WidgetCardItem? item) if (!HomePageContext.IsAnyItemRightClicked) return; + var flyout = HomePageContext.ItemContextFlyoutMenu; EventHandler flyoutClosed = null!; flyoutClosed = (s, e) => { - HomePageContext.ItemContextFlyoutMenu!.Closed -= flyoutClosed; + flyout!.Closed -= flyoutClosed; ListedItem listedItem = new(null!) { @@ -87,7 +88,7 @@ private void OpenProperties(WidgetCardItem? item) FilePropertiesHelpers.OpenPropertiesWindow(listedItem, AppInstance); }; - HomePageContext.ItemContextFlyoutMenu!.Closed += flyoutClosed; + flyout!.Closed += flyoutClosed; } private void OpenInNewPane(WidgetCardItem? item) @@ -119,7 +120,7 @@ private void AdaptiveGridView_RightTapped(object sender, RightTappedRoutedEventA // Hook events itemContextMenuFlyout.Opening += (sender, e) => App.LastOpenedFlyout = sender as CommandBarFlyout; - itemContextMenuFlyout.Opened += (sender, e) => OnRightClickedItemChanged(null, null); + itemContextMenuFlyout.Closed += (sender, e) => OnRightClickedItemChanged(null, null); FlyoutItemPath = item.Path; diff --git a/src/Files.App/UserControls/Widgets/HomePageWidget.cs b/src/Files.App/UserControls/Widgets/HomePageWidget.cs index 551333c4ee93..c0ddd993940a 100644 --- a/src/Files.App/UserControls/Widgets/HomePageWidget.cs +++ b/src/Files.App/UserControls/Widgets/HomePageWidget.cs @@ -59,7 +59,7 @@ public void Button_RightTapped(object sender, RightTappedRoutedEventArgs e) // Hook events itemContextMenuFlyout.Opening += (sender, e) => App.LastOpenedFlyout = sender as CommandBarFlyout; - itemContextMenuFlyout.Opened += (sender, e) => OnRightClickedItemChanged(null, null); + itemContextMenuFlyout.Closed += (sender, e) => OnRightClickedItemChanged(null, null); FlyoutItemPath = item.Path; diff --git a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs index 8994d6f0a7af..cbe1adec99e8 100644 --- a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs @@ -368,15 +368,16 @@ private void OpenProperties(FolderCardItem item) if (!HomePageContext.IsAnyItemRightClicked) return; + var flyout = HomePageContext.ItemContextFlyoutMenu; EventHandler flyoutClosed = null!; flyoutClosed = (s, e) => { - HomePageContext.ItemContextFlyoutMenu!.Closed -= flyoutClosed; + flyout!.Closed -= flyoutClosed; CardPropertiesInvoked?.Invoke(this, new QuickAccessCardEventArgs { Item = item.Item }); }; - HomePageContext.ItemContextFlyoutMenu!.Closed += flyoutClosed; + flyout!.Closed += flyoutClosed; } public override async Task PinToFavoritesAsync(WidgetCardItem item) diff --git a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs index 5d04bd6e5c97..9e2fdf6b115f 100644 --- a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs @@ -124,7 +124,7 @@ private void ListView_RightTapped(object sender, RightTappedRoutedEventArgs e) // Hook events itemContextMenuFlyout.Opening += (sender, e) => App.LastOpenedFlyout = sender as CommandBarFlyout; - itemContextMenuFlyout.Opened += (sender, e) => OnRightClickedItemChanged(null, null); + itemContextMenuFlyout.Closed += (sender, e) => OnRightClickedItemChanged(null, null); FlyoutItemPath = item.Path; @@ -242,14 +242,15 @@ private void OpenFileLocation(RecentItem item) private void OpenProperties(RecentItem item) { + var flyout = HomePageContext.ItemContextFlyoutMenu; EventHandler flyoutClosed = null!; flyoutClosed = async (s, e) => { - HomePageContext.ItemContextFlyoutMenu!.Closed -= flyoutClosed; + flyout!.Closed -= flyoutClosed; var listedItem = await UniversalStorageEnumerator.AddFileAsync(await BaseStorageFile.GetFileFromPathAsync(item.Path), null, default); FilePropertiesHelpers.OpenPropertiesWindow(listedItem, associatedInstance); }; - HomePageContext.ItemContextFlyoutMenu!.Closed += flyoutClosed; + flyout!.Closed += flyoutClosed; } private async Task UpdateRecentsListAsync(NotifyCollectionChangedEventArgs e)