Files icon indicating copy to clipboard operation
Files copied to clipboard

Feature: Added support for dragging recent files

Open Krytan opened this issue 1 year ago • 27 comments

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

Closes #8282

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

1 - Open Files app 2 - Go to Home 3 - Scroll down to Recent files 4 - Dragging files should be possible

How does dragging work?

Dragging recent files to other programs or outside Files will trigger "copy" similar to windows File explorer, drags files to the desired location without changing the main path.

Dragging recent files inside the app Files will trigger "Move to", drags files to the desired location changing the main path to the new desired path, similar to when dragging files from Documents or Downloads. file explorer uses "Copy" instead of "Move to" for this.

I can change to copy as well if it makes more sense.

Krytan avatar Jun 05 '24 12:06 Krytan

I'm trying to drag some text files into Notepad and while they can be dragged, dropping them into Notepad isn't opening the file.

yaira2 avatar Jun 05 '24 21:06 yaira2

Interesting, I will try to simulate that, I know that it works with google drive the web version

Krytan avatar Jun 05 '24 22:06 Krytan

I'm trying to drag some text files into Notepad and while they can be dragged, dropping them into Notepad isn't opening the file.

That is a known issue. It would be great if we could fix it. https://github.com/files-community/Files/issues/11735

hishitetsu avatar Jun 05 '24 23:06 hishitetsu

@hishitetsu Correct I checked with downloads and documents and they don't work when copying to notepad or text editor applications as well but I found I way to fix this

Krytan avatar Jun 05 '24 23:06 Krytan

@yaira2 @hishitetsu dragging text files into Notepad or any text editor should work now for recent files

Krytan avatar Jun 05 '24 23:06 Krytan

Shouldn't it be possible to perform operations other than copying? Ideally, the process should be common to this.

https://github.com/files-community/Files/blob/fd18e70dfcc677978fdb1f46ba2cfd2a45045379/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs#L88

What other operations you got in mind? I believe the reason windows file explorer only uses copy for recent files is because recent files contain multiple files or folders from different paths/directories, so in case an accident happen the user is just copying and never messing with the original path/directory.

Krytan avatar Jun 06 '24 00:06 Krytan

I tried that fix before, but iirc it didn't work when dragging multiple text files. However, the widget doesn't allow multiple files to be dragged, so it may be fine.

hishitetsu avatar Jun 06 '24 00:06 hishitetsu

What other operations you got in mind? I believe the reason windows file explorer only uses copy for recent files is because recent files contain multiple files or folders from different paths/directories, so in case an accident happen the user is just copying and never messing with the original path/directory.

What about the Link operation?

hishitetsu avatar Jun 06 '24 00:06 hishitetsu

I see. that could be okay to have I don't see any potential issues on it, I don't know why file explorer don't have that actually, if is desirable I can add it too

Krytan avatar Jun 06 '24 00:06 Krytan

I see. that could be okay to have I don't see any potential issues on it, I don't know why file explorer don't have that actually, if is desirable I can add it too

If Explorer only supports the copy operation, then leave it as it is.

hishitetsu avatar Jun 06 '24 16:06 hishitetsu

@hishitetsu Explorer also supports Link operation and I am being struggling trying to implement it I was looking at your code and pretty much followed everything but still getting the circle with a cross, is not allowing me to do the link when I press shift

Krytan avatar Jun 06 '24 19:06 Krytan

@hishitetsu Explorer also supports Link operation and I am being struggling trying to implement it I was looking at your code and pretty much followed everything but still getting the circle with a cross, is not allowing me to do the link when I press shift

To do the link, don't you press the Alt key? Link operation worked when I simply replaced Copy in your PR with Link.

hishitetsu avatar Jun 07 '24 12:06 hishitetsu

@hishitetsu Right. I was trying to add dragover but found out I didn't needed to was simpler than I thought so now link operator works as well.

Krytan avatar Jun 07 '24 16:06 Krytan

@hishitetsu added limit for reading text file to 50 mb, and added a new method for ReadFileContent, felt that there was many ifs in one section.

Krytan avatar Jun 08 '24 19:06 Krytan

I have also found that I can't drag from recent files on the home page in Explorer to Notepad, even though I can drag from normal folders. So, I guess WinUI 3 doesn't support dragging files to Notepad.

hishitetsu avatar Jun 09 '24 02:06 hishitetsu

I have found that it inserts text into the already open tab rather than newly opening the dragged file when dragging a file into Notepad. I'll wait for @yaira2 to decide if this is fine.

That's correct and is not the expected behavior. the expected behavior is to open the file into notepad with the text on the tab. righter than creating a new file.

Krytan avatar Jun 09 '24 12:06 Krytan

I have also found that I can't drag from recent files on the home page in Explorer to Notepad, even though I can drag from normal folders. So, I guess WinUI 3 doesn't support dragging files to Notepad.

Correct. explorer doesn't let dragging from recent files to text editor applications. whenever WinUI 3 dosen't support it I am not so sure.

Krytan avatar Jun 09 '24 16:06 Krytan

The only problem now with this PR is drag-and-drop to Notepad. I think it would be better to delete those codes so that this PR can be merged.

hishitetsu avatar Jun 17 '24 10:06 hishitetsu

I agree since dragging to notepad doesn't work anywhere else in the program and no helpful source was found. so one step at time.

Krytan avatar Jun 18 '24 20:06 Krytan

Deleted text to be dropped into text editor for example notepad because of an unexpected issue causing the texteditor to open a new file instead of editing in the same file. moreover FileExplorer also doesn't allow Recent files to drop text into notepad or texteditor apps.

Krytan avatar Jun 18 '24 20:06 Krytan

@hishitetsu I see it is because the SideBar also have a drag code that changes the operation to move hmmm to fix this a solution would be in the sidebar.cs add a if estatment that if the file is coming from recent, change the operation to copy

Krytan avatar Jun 20 '24 13:06 Krytan

@hishitetsu I see it is because the SideBar also have a drag code that changes the operation to move hmmm to fix this a solution would be in the sidebar.cs add a if estatment that if the file is coming from recent, change the operation to copy

I agree.

hishitetsu avatar Jun 21 '24 00:06 hishitetsu

What's the status of this PR, ready for merge?

yaira2 avatar Jul 09 '24 14:07 yaira2

This issue hasn't been fixed. https://github.com/files-community/Files/pull/15555#pullrequestreview-2129136824

hishitetsu avatar Jul 09 '24 23:07 hishitetsu

I found a new problem. When dropping on the desktop I can only copy or link, but when dropping on the sidebar I can move the item.

@Krytan are you still planning to work on this?

yaira2 avatar Aug 26 '24 15:08 yaira2