From 11d6a173144061f58ef40d089bbb8fa8100ea0a3 Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Thu, 30 Oct 2025 11:42:17 +0530 Subject: [PATCH 1/6] Fix: Hidden inappropriate context menu items for Recycle Bin. --- .../Factories/ContentPageContextFlyoutFactory.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index f0947f14af60..d5ce11aebe2a 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -380,7 +380,10 @@ public static List GetBaseItemMenuItems( { IsVisible = currentInstanceViewModel.IsPageTypeRecycleBin && itemsSelected, }.Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItem).Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItem) + { + IsVisible = !areAllItemsFolders + }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItemWithApplicationPicker) { Tag = "OpenWith", @@ -409,15 +412,15 @@ public static List GetBaseItemMenuItems( new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenFileLocation).Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTab) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && Commands.OpenInNewTab.IsExecutable + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && Commands.OpenInNewTab.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindow) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && Commands.OpenInNewWindow.IsExecutable + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && Commands.OpenInNewWindow.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPane) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && Commands.OpenInNewPane.IsExecutable + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && Commands.OpenInNewPane.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin }.Build(), new ContextMenuFlyoutItemViewModel() { @@ -479,7 +482,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.CreateFolderWithSelection) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowCreateFolderWithSelection && itemsSelected + IsVisible = UserSettingsService.GeneralSettingsService.ShowCreateFolderWithSelection && itemsSelected && !currentInstanceViewModel.IsPageTypeRecycleBin }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.CreateShortcut) { From 78145465176bdea859786f7e97153b683ee254db Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Thu, 30 Oct 2025 11:53:56 +0530 Subject: [PATCH 2/6] Fix: Hidden inappropriate context menu items for Recycle Bin items. --- src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index d5ce11aebe2a..168853c27916 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -382,7 +382,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItem) { - IsVisible = !areAllItemsFolders + IsVisible = !(currentInstanceViewModel.IsPageTypeRecycleBin && areAllItemsFolders) }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItemWithApplicationPicker) { From 9849acbfc045385826c0669fc6e8d946635c3680 Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Fri, 31 Oct 2025 12:56:44 +0530 Subject: [PATCH 3/6] Fix: Set IsExecutable property for navigation actions to prevent execution in Recycle Bin via Command Palette. --- src/Files.App/Actions/FileSystem/OpenItemAction.cs | 4 +++- .../Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs | 1 + .../Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs | 1 + .../Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Actions/FileSystem/OpenItemAction.cs b/src/Files.App/Actions/FileSystem/OpenItemAction.cs index 8d9d6bb3aab3..d3ea61bf6c57 100644 --- a/src/Files.App/Actions/FileSystem/OpenItemAction.cs +++ b/src/Files.App/Actions/FileSystem/OpenItemAction.cs @@ -27,7 +27,9 @@ public HotKey HotKey public bool IsExecutable => context.HasSelection && !(context.ShellPage is ColumnShellPage && - context.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder); + context.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder) && + !(context.PageType == ContentPageTypes.RecycleBin && + context.SelectedItems.All(x => x.IsFolder)); public OpenItemAction() { diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs index 5fe4ec301e7e..c7e9e9d1ac47 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs @@ -17,6 +17,7 @@ public string Description => Strings.OpenDirectoryInNewPaneDescription.GetLocalizedResource(); public virtual bool IsExecutable => + ContentPageContext.PageType != ContentPageTypes.RecycleBin && ContentPageContext.SelectedItem is not null && ContentPageContext.SelectedItem.IsFolder; diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs index df863028f7a4..d8b77afb8262 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs @@ -25,6 +25,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && ContentPageContext.ShellPage.SlimContentPage is not null && + ContentPageContext.PageType != ContentPageTypes.RecycleBin && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count; diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index d89469546cfb..2715c9dd8512 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -30,6 +30,7 @@ public virtual bool IsAccessibleGlobally public virtual bool IsExecutable => ContentPageContext.ShellPage is not null && ContentPageContext.ShellPage.SlimContentPage is not null && + ContentPageContext.PageType != ContentPageTypes.RecycleBin && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count; From 75908c590d66851902444c20fd98f86bbf4847ae Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Mon, 3 Nov 2025 15:58:11 +0530 Subject: [PATCH 4/6] Code Quality: Removed redundant RecycleBin checks from context menu factory and to handle by IsExecutable in the respective action classes. --- .../Data/Factories/ContentPageContextFlyoutFactory.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index 168853c27916..45866f441b7a 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -380,10 +380,7 @@ public static List GetBaseItemMenuItems( { IsVisible = currentInstanceViewModel.IsPageTypeRecycleBin && itemsSelected, }.Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItem) - { - IsVisible = !(currentInstanceViewModel.IsPageTypeRecycleBin && areAllItemsFolders) - }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItem).Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenItemWithApplicationPicker) { Tag = "OpenWith", @@ -412,15 +409,15 @@ public static List GetBaseItemMenuItems( new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenFileLocation).Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTab) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && Commands.OpenInNewTab.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && Commands.OpenInNewTab.IsExecutable }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindow) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && Commands.OpenInNewWindow.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && Commands.OpenInNewWindow.IsExecutable }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPane) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && Commands.OpenInNewPane.IsExecutable && !currentInstanceViewModel.IsPageTypeRecycleBin + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && Commands.OpenInNewPane.IsExecutable }.Build(), new ContextMenuFlyoutItemViewModel() { From 4cfff810190338253637e31b4dd8da6ce89e01eb Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Mon, 3 Nov 2025 16:54:22 +0530 Subject: [PATCH 5/6] Fix: Fixed RecycleBin blocking for Open, Open With, and Pin to Sidebar --- src/Files.App/Actions/FileSystem/OpenItemAction.cs | 4 ++-- src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Actions/FileSystem/OpenItemAction.cs b/src/Files.App/Actions/FileSystem/OpenItemAction.cs index d3ea61bf6c57..1854df4e007f 100644 --- a/src/Files.App/Actions/FileSystem/OpenItemAction.cs +++ b/src/Files.App/Actions/FileSystem/OpenItemAction.cs @@ -28,8 +28,7 @@ public HotKey HotKey context.HasSelection && !(context.ShellPage is ColumnShellPage && context.SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder) && - !(context.PageType == ContentPageTypes.RecycleBin && - context.SelectedItems.All(x => x.IsFolder)); + context.PageType != ContentPageTypes.RecycleBin; public OpenItemAction() { @@ -69,6 +68,7 @@ public RichGlyph Glyph public bool IsExecutable => context.HasSelection && + context.PageType != ContentPageTypes.RecycleBin && context.SelectedItems.All(i => (i.PrimaryItemAttribute == StorageItemTypes.File && !i.IsShortcut && !i.IsExecutable) || (i.PrimaryItemAttribute == StorageItemTypes.Folder && i.IsArchive)); diff --git a/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs b/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs index c4df6940932c..9f6f7e4c5f4a 100644 --- a/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs +++ b/src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs @@ -48,6 +48,9 @@ public async Task ExecuteAsync(object? parameter = null) private bool GetIsExecutable() { + if (context.PageType == ContentPageTypes.RecycleBin) + return false; + string[] pinnedFolders = [.. App.QuickAccessManager.Model.PinnedFolders]; return context.HasSelection From 0ac06d4b106a42648e557dba4ea6ffcfad8b7e35 Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Mon, 3 Nov 2025 23:07:45 +0530 Subject: [PATCH 6/6] Code Quality: Removed redundant RecycleBin check from CreateFolderWithSelection --- src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index 45866f441b7a..f0947f14af60 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -479,7 +479,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.CreateFolderWithSelection) { - IsVisible = UserSettingsService.GeneralSettingsService.ShowCreateFolderWithSelection && itemsSelected && !currentInstanceViewModel.IsPageTypeRecycleBin + IsVisible = UserSettingsService.GeneralSettingsService.ShowCreateFolderWithSelection && itemsSelected }.Build(), new ContextMenuFlyoutItemViewModelBuilder(Commands.CreateShortcut) {