-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Dragging Folders from File System into VS Code PWA #141935
Comments
fyi @bpasero |
I have done some of my own testing since this bug, and I stumbled on another issue since my original comment, not having to do with https://vscode.dev's implementation. I found the issue on Chrome OS, and I think there may an additional implementation issue in terms of the browser itself. I was going to try an implement a feature like VS Code's Explorer myself, so I can learn more about how it works, and I found out any time you have a directory as a selected item in your drag selection, it will prevent any I will be testing my original issue comment above on other operating systems to see if the issue is still present, or if the whole problem was caused by Chrome OS's implementation issue. I will do more testing for this new find, and if further results have the same outcome, I will submit a Chrome OS-specific issue report as well. *Edit: For the image below, first I dragged a standard If you have a Chrome OS device and you'd like to see this issue also, my test code was using the snippet provided by the web.dev team in the File System Access API article, under the Drag and Drop Integration section. <script>
/* Based on the snippet from https://web.dev/file-system-access/#drag-and-drop-integration */
document.addEventListener('dragover',e => e.preventDefault());
document.addEventListener('drop', async (e) => {
e.preventDefault();
console.log("Item dropped!");
const fileHandlesPromises = [...e.dataTransfer.items]
.filter((item) => item.kind === 'file')
.map((item) => item.getAsFileSystemHandle());
for await (const handle of fileHandlesPromises) {
if (handle.kind === 'directory') {
console.log(`Directory: ${handle.name}`);
} else {
console.log(`File: ${handle.name}`);
}
}
});
</script> |
Alright, did some testing with my own code snippet from the last comment on Windows, and everything is behaving as expected in terms of browser implementation. The original feature request for https://vscode.dev is still accurate as well, it looks like the dropping directories into the app isn't supported in the browser as of now, regardless of platform implementation issues, like the one on Chrome OS. Summary:
|
(Filed the Chrome OS bug as https://crbug.com/1295210.) |
This was when I started looking into the project again just a few days ago! I noticed that you couldn't drag a folder into the workspace for an https://vscode.dev window, so I thought I'd make a demo to show off how it could work. Turns out I also happened to find a bug in Chrome OS! You can read all about that here: microsoft/vscode#141935 That bug report spurred a few more that I also helped out with, WICG/file-system-access#361 and https://bugs.chromium.org/p/chromium/issues/detail?id=1295210. Pretty crazy to be contributing to open source, this is so fun!!!
This was when I started looking into the project again just a few days ago! I noticed that you couldn't drag a folder into the workspace for an https://vscode.dev window, so I thought I'd make a demo to show off how it could work. Turns out I also happened to find a bug in Chrome OS! You can read all about that here: microsoft/vscode#141935 That bug report spurred a few more that I also helped out with, WICG/file-system-access#361 and https://bugs.chromium.org/p/chromium/issues/detail?id=1295210. Pretty crazy to be contributing to open source, this is so fun!!!
Pushed a couple of changes that adds This already enables a few interesting scenarios:
I need to test this a bit more around handling N folders being dropped and supporting to add a folder to the workspace when dropped over the explorer, not sure yet why I am not getting asked whether I want to add the folder to the workspace or copy it into. We probably have some Also interesting how we can support this when a remote (such as GH) is opened. We can still support to open local files, but probably not folders. |
Did a complete test of all our drop sensitive locations and pushed some more changes.
|
Is there a time frame of when it may be likely to see this available in the stable https://vscode.dev @bpasero? |
@Offroaders123 here you go:
It is fine to stay on insiders, we in the team use it every day. |
With the standard Electron version of VS Code, the user is able to drag folders into the workspace from the File System, and it will open that folder in the current window.
I tried using this feature while editing my projects with the PWA version of VS Code at https://vscode.dev, however the folder did not open in the Workspace, as it does with the Electron version. I was using the VS Code PWA on Chrome OS with Chrome 97 installed.
In browsers that support the File System Access API, element
drop
events have the ability to returnFileSystemDirectoryHandle
objects after using thegetAsFileSystemHandle()
method on anyDataTransferItem
entries present on the event, if the user is dragging a folder. This would allow the user to drop a folder into the Workspace, and using theDataTransferItem
entry to openthat folder with the Workspace.
This would be a very helpful feature to also have with the PWA version, it provides another way that the user can open folders from the file system, alongside the currently available "Open Folder" button in the Explorer menu.
Great work on the progress of the PWA by the way, it is working awesome so far!
Here's a reference to the information I found about the
DataTransferItem.getAsFileSystemHandle()
feature I mentioned above:https://web.dev/file-system-access/#drag-and-drop-integration
The text was updated successfully, but these errors were encountered: