Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where drag and drop from Edge didn't work #14976

Merged
merged 2 commits into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs
Expand Up @@ -245,14 +245,14 @@ public async Task<ReturnResult> RestoreItemsFromTrashAsync(IEnumerable<IStorageI
{
return await RecycleItemsFromClipboard(packageView, destination, UserSettingsService.FoldersSettingsService.DeleteConfirmationPolicy, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
{
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Move))
{
return await MoveItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
{
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Link))
{
// Open with piggybacks off of the link operation, since there isn't one for it
Expand Down
9 changes: 6 additions & 3 deletions src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs
Expand Up @@ -123,7 +123,8 @@ public async Task DragOverAsync(DragEventArgs e)
if (pwd.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
{
Expand All @@ -138,7 +139,8 @@ public async Task DragOverAsync(DragEventArgs e)
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (draggedItems.Any(x =>
x.Item is ZipStorageFile ||
Expand All @@ -151,7 +153,8 @@ public async Task DragOverAsync(DragEventArgs e)
else if (draggedItems.AreItemsInSameDrive(_associatedInstance.FilesystemViewModel.WorkingDirectory))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down
Expand Up @@ -410,7 +410,8 @@ public async Task PathBoxItem_DragOver(object sender, DragEventArgs e)
{
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), pathBoxItem.Title);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}

deferral.Complete();
Expand Down
15 changes: 10 additions & 5 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Expand Up @@ -1130,7 +1130,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
if (locationItem.Path.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Alt) || rawEvent.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
{
Expand All @@ -1145,7 +1146,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (storageItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
|| ZipStorageFolder.IsZipPath(locationItem.Path))
Expand All @@ -1156,7 +1158,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
else if (locationItem.IsDefaultLocation || storageItems.AreItemsInSameDrive(locationItem.Path))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down Expand Up @@ -1204,12 +1207,14 @@ private async Task HandleDriveItemDragOverAsync(DriveItem driveItem, ItemDragOve
else if (args.RawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (storageItems.AreItemsInSameDrive(driveItem.Path))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/Files.App/Views/Layouts/BaseLayoutPage.cs
Expand Up @@ -1045,7 +1045,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
|| ZipStorageFolder.IsZipPath(item.ItemPath))
Expand All @@ -1056,7 +1057,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
else if (draggedItems.AreItemsInSameDrive(item.ItemPath))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down