Skip to content

Commit 8d15485

Browse files
authored
Allow deletion from search results. (#11655)
1 parent 0cc8d54 commit 8d15485

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Files.App/Actions/FileSystem/DeleteItemAction.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal class DeleteItemAction : ObservableObject, IAction
2525

2626
public HotKey HotKey { get; } = new(VirtualKey.Delete);
2727

28-
public bool IsExecutable => context.PageType is not ContentPageTypes.SearchResults && context.HasSelection;
28+
public bool IsExecutable => context.HasSelection;
2929

3030
public DeleteItemAction()
3131
{
@@ -38,19 +38,16 @@ public async Task ExecuteAsync()
3838
return;
3939

4040
var items = context.SelectedItems.Select(item => StorageHelpers.FromPathAndType(item.ItemPath,
41-
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
41+
item.PrimaryItemAttribute is StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
42+
4243
await context.ShellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, true, true);
44+
await context.ShellPage.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync();
4345
}
4446

4547
public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
4648
{
47-
switch (e.PropertyName)
48-
{
49-
case nameof(IContentPageContext.PageType):
50-
case nameof(IContentPageContext.HasSelection):
51-
OnPropertyChanged(nameof(IsExecutable));
52-
break;
53-
}
49+
if (e.PropertyName is nameof(IContentPageContext.HasSelection))
50+
OnPropertyChanged(nameof(IsExecutable));
5451
}
5552
}
5653
}

0 commit comments

Comments
 (0)