Feature: Added support for dragging recent files
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.
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.
Interesting, I will try to simulate that, I know that it works with google drive the web version
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 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
@yaira2 @hishitetsu dragging text files into Notepad or any text editor should work now for recent files
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.
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.
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?
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
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 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
@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 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.
@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.
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.
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.
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.
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.
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.
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.
@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
@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.
What's the status of this PR, ready for merge?
This issue hasn't been fixed. https://github.com/files-community/Files/pull/15555#pullrequestreview-2129136824
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?