Skip to content

Commit 7982242

Browse files
authored
Fix: Fixed an issue where Columns View was incorrectly enabled for Recycle Bin (#17803)
1 parent 048d148 commit 7982242

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/Files.App/Actions/Display/LayoutAction.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public override HotKey HotKey
8282
[GeneratedRichCommand]
8383
internal sealed partial class LayoutColumnsAction : ToggleLayoutAction
8484
{
85+
private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
86+
8587
protected override LayoutTypes LayoutType
8688
=> LayoutTypes.Columns;
8789

@@ -96,6 +98,24 @@ public override RichGlyph Glyph
9698

9799
public override HotKey HotKey
98100
=> new(Keys.Number5, KeyModifiers.CtrlShift);
101+
102+
public override bool IsExecutable
103+
=> ContentPageContext.PageType is not ContentPageTypes.RecycleBin;
104+
105+
public LayoutColumnsAction()
106+
{
107+
ContentPageContext.PropertyChanged += ContentPageContext_PropertyChanged;
108+
}
109+
110+
private void ContentPageContext_PropertyChanged(object? sender, PropertyChangedEventArgs e)
111+
{
112+
switch (e.PropertyName)
113+
{
114+
case nameof(IContentPageContext.PageType):
115+
OnPropertyChanged(nameof(IsExecutable));
116+
break;
117+
}
118+
}
99119
}
100120

101121
[GeneratedRichCommand]

src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,30 @@ public static void SetLayoutPreferencesForPath(string path, LayoutPreferencesIte
486486

487487
private static LayoutPreferencesItem? GetLayoutPreferencesForPath(string path)
488488
{
489+
//Recycle Bin does not support Column View due to navigation conflicts with hierarchical display
490+
//Fall back to Details View when Column View is configured
491+
if (path.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
492+
{
493+
var trimmedPath = path.TrimPath() ?? string.Empty;
494+
495+
var recycleBinPreference = SafetyExtensions.IgnoreExceptions(() =>
496+
{
497+
var folderFRN = Win32Helper.GetFolderFRN(trimmedPath);
498+
499+
return GetLayoutPreferencesFromDatabase(trimmedPath, folderFRN)
500+
?? GetLayoutPreferencesFromAds(trimmedPath, folderFRN);
501+
}, App.Logger);
502+
503+
if (recycleBinPreference is not null && recycleBinPreference.LayoutMode != FolderLayoutModes.ColumnView)
504+
return recycleBinPreference;
505+
506+
var defaultPref = new LayoutPreferencesItem();
507+
if (defaultPref.LayoutMode == FolderLayoutModes.ColumnView)
508+
defaultPref.LayoutMode = FolderLayoutModes.DetailsView;
509+
510+
return defaultPref;
511+
}
512+
489513
if (!UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories)
490514
{
491515
path = path.TrimPath() ?? string.Empty;

0 commit comments

Comments
 (0)