Skip to content

Commit

Permalink
Fix: Fixed issue where the properties window could not be opened on t…
Browse files Browse the repository at this point in the history
…he home page (files-community#14385)
  • Loading branch information
hishitetsu authored Jan 8, 2024
1 parent bc00d61 commit 35cc6ad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,15 @@ private void OpenProperties(DriveCardItem item)
if (!HomePageContext.IsAnyItemRightClicked)
return;

var flyout = HomePageContext.ItemContextFlyoutMenu;
EventHandler<object> 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)
Expand Down
7 changes: 4 additions & 3 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ private void OpenProperties(WidgetCardItem? item)
if (!HomePageContext.IsAnyItemRightClicked)
return;

var flyout = HomePageContext.ItemContextFlyoutMenu;
EventHandler<object> flyoutClosed = null!;
flyoutClosed = (s, e) =>
{
HomePageContext.ItemContextFlyoutMenu!.Closed -= flyoutClosed;
flyout!.Closed -= flyoutClosed;

ListedItem listedItem = new(null!)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/Widgets/HomePageWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,16 @@ private void OpenProperties(FolderCardItem item)
if (!HomePageContext.IsAnyItemRightClicked)
return;

var flyout = HomePageContext.ItemContextFlyoutMenu;
EventHandler<object> 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)
Expand Down
7 changes: 4 additions & 3 deletions src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -242,14 +242,15 @@ private void OpenFileLocation(RecentItem item)

private void OpenProperties(RecentItem item)
{
var flyout = HomePageContext.ItemContextFlyoutMenu;
EventHandler<object> 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)
Expand Down

0 comments on commit 35cc6ad

Please sign in to comment.