Skip to content

Commit d50ed7c

Browse files
authored
Fix: Fixed issue where drag and drop from Edge didn't work (#14976)
1 parent 0965661 commit d50ed7c

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ public async Task<ReturnResult> PerformOperationTypeAsync(
245245
{
246246
return await RecycleItemsFromClipboard(packageView, destination, UserSettingsService.FoldersSettingsService.DeleteConfirmationPolicy, registerHistory);
247247
}
248-
else if (operation.HasFlag(DataPackageOperation.Copy))
249-
{
250-
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
251-
}
252248
else if (operation.HasFlag(DataPackageOperation.Move))
253249
{
254250
return await MoveItemsFromClipboard(packageView, destination, showDialog, registerHistory);
255251
}
252+
else if (operation.HasFlag(DataPackageOperation.Copy))
253+
{
254+
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
255+
}
256256
else if (operation.HasFlag(DataPackageOperation.Link))
257257
{
258258
// Open with piggybacks off of the link operation, since there isn't one for it

src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public async Task DragOverAsync(DragEventArgs e)
123123
if (pwd.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
124124
{
125125
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
126-
e.AcceptedOperation = DataPackageOperation.Move;
126+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
127+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
127128
}
128129
else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
129130
{
@@ -138,7 +139,8 @@ public async Task DragOverAsync(DragEventArgs e)
138139
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
139140
{
140141
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
141-
e.AcceptedOperation = DataPackageOperation.Move;
142+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
143+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
142144
}
143145
else if (draggedItems.Any(x =>
144146
x.Item is ZipStorageFile ||
@@ -151,7 +153,8 @@ x.Item is ZipStorageFile ||
151153
else if (draggedItems.AreItemsInSameDrive(_associatedInstance.FilesystemViewModel.WorkingDirectory))
152154
{
153155
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
154-
e.AcceptedOperation = DataPackageOperation.Move;
156+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
157+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
155158
}
156159
else
157160
{

src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ x.Item is ZipStorageFile ||
410410
{
411411
e.DragUIOverride.IsCaptionVisible = true;
412412
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), pathBoxItem.Title);
413-
e.AcceptedOperation = DataPackageOperation.Move;
413+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
414+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
414415
}
415416

416417
deferral.Complete();

src/Files.App/ViewModels/UserControls/SidebarViewModel.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
11301130
if (locationItem.Path.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
11311131
{
11321132
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
1133-
operationType = DataPackageOperation.Move;
1133+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1134+
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
11341135
}
11351136
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Alt) || rawEvent.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
11361137
{
@@ -1145,7 +1146,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
11451146
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
11461147
{
11471148
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
1148-
operationType = DataPackageOperation.Move;
1149+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1150+
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
11491151
}
11501152
else if (storageItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
11511153
|| ZipStorageFolder.IsZipPath(locationItem.Path))
@@ -1156,7 +1158,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
11561158
else if (locationItem.IsDefaultLocation || storageItems.AreItemsInSameDrive(locationItem.Path))
11571159
{
11581160
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
1159-
operationType = DataPackageOperation.Move;
1161+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1162+
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
11601163
}
11611164
else
11621165
{
@@ -1204,12 +1207,14 @@ private async Task HandleDriveItemDragOverAsync(DriveItem driveItem, ItemDragOve
12041207
else if (args.RawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
12051208
{
12061209
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
1207-
operationType = DataPackageOperation.Move;
1210+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1211+
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
12081212
}
12091213
else if (storageItems.AreItemsInSameDrive(driveItem.Path))
12101214
{
12111215
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
1212-
operationType = DataPackageOperation.Move;
1216+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1217+
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
12131218
}
12141219
else
12151220
{

src/Files.App/Views/Layouts/BaseLayoutPage.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
10521052
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
10531053
{
10541054
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
1055-
e.AcceptedOperation = DataPackageOperation.Move;
1055+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1056+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
10561057
}
10571058
else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
10581059
|| ZipStorageFolder.IsZipPath(item.ItemPath))
@@ -1063,7 +1064,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
10631064
else if (draggedItems.AreItemsInSameDrive(item.ItemPath))
10641065
{
10651066
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
1066-
e.AcceptedOperation = DataPackageOperation.Move;
1067+
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
1068+
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
10671069
}
10681070
else
10691071
{

0 commit comments

Comments
 (0)