Skip to content

web: Fix files_dropped implementation - #123543

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Faless:web/fix_drag_drop
Sep 24, 2026
Merged

Repiteo merged 1 commit into
godotengine:masterfrom
Faless:web/fix_drag_drop

Conversation

@Faless

@Faless Faless commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

OS files and folders dropping inside the browser window has been supported for a long time, but the original implementation based on temporary "drop" folders was quite hacky and broken.

This commit fixes two main issues:

  • Dropped folders are now copied in the temporary one respecting the original structure (instead of copying all files to the top level).
  • The emitted signal now only reports the files/folders that were actually dropped, not all files in the dropped folders (this is a consequence of the above).

This brings it more in line with other platforms.

The JS code has been refactored for better processing, and the temporary deletion is now delegated to the display server.

The "persistentDrops" hack has also been dropped in favor of a localized solution in the project manager.

This might "break compat" if you relied on the (purposely undocumented) "persistentDrops" config option, or the bug causing all files to be dropped in the root of the temporary folder.

drag_drop_editor.mp4

Note

We have an opportunity in the editor, to do some more filtering on what we copy by monkey-patching the controller (e.g. excluding .godot and .git from folders, and only import folders containing a project.godot file and its subfolder).

I think we should do that after/on top of #123149 (I have a tentative implementation in a separate branch).

@Faless Faless added this to the 4.8 milestone Sep 16, 2026
@Faless
Faless requested review from a team as code owners September 16, 2026 08:23
@Faless
Faless force-pushed the web/fix_drag_drop branch 2 times, most recently from fd45c85 to 531ba35 Compare September 16, 2026 11:18
Comment thread platform/web/js/libs/library_godot_input.js Outdated
Comment thread editor/project_manager/project_manager.cpp
Comment thread editor/project_manager/project_manager.cpp
Comment thread editor/project_manager/project_manager.cpp
};
if (!f['path']) {
f['path'] = f['name'];
MAX_DROP_SIZE: 200 * 1024 * 1024,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could eventually be turned onto an EditorSetting in case someone wants to import a really big project (i would still agree the web editor is not home for such a project)

Comment thread platform/web/js/libs/library_godot_input.js Outdated
Comment thread platform/web/js/libs/library_godot_input.js
Comment thread editor/project_manager/project_manager.cpp
@Faless
Faless force-pushed the web/fix_drag_drop branch 2 times, most recently from a823a1f to 4cf2db5 Compare September 16, 2026 18:12
@Faless
Faless requested a review from a team as a code owner September 16, 2026 18:12
Comment thread platform/web/js/libs/library_godot_input.js Outdated
Comment thread doc/classes/DisplayServer.xml
Comment thread editor/project_manager/project_manager.cpp Outdated
Comment thread editor/project_manager/project_manager.cpp Outdated
Comment thread platform/web/display_server_web.cpp Outdated
@Faless
Faless force-pushed the web/fix_drag_drop branch 4 times, most recently from 7e4beb8 to a323aa2 Compare September 18, 2026 08:31
@Faless

Faless commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

From #123543 (comment)
this could be further refactored to run concurrent promises and abort them with an AbortController (which has been widely available for a while at this point).

That would increase drop/copy speed by a lot! I'm leaving it for a separate PR, though, since it has a higher chance of breaking something.

I ended up refactoring that code without the AbortController since I realized that we were actually not chaining the promises correctly and thus not stopping after the first error anyway.

This is because we were in fact processing all dirs/files "immediately" in any case, by queuing promises in a "pending" state.

With my last changes we instead queue functions that return the desired promises, allowing to chain them correctly and stopping when the first error is encountered.

By removing the setTimeout debounce and relying on proper chaining the copy process is now much faster:

faster_drop.mp4

@akien-mga akien-mga changed the title web: Fix files_dropped implementation web: Fix files_dropped implementation Sep 23, 2026

@akien-mga akien-mga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@Repiteo

This comment was marked as resolved.

OS files and folders dropping inside the browser window has been
supported for a long time, but the original implementation based on
temporary "drop" folders was quite hacky and broken.

This commit fixes two main issues:
- Dropped folders are now copied in the temporary one respecting the
  original structure (instead of copying all files to the top level).
- The emitted signal now only reports the files/folders that were
  actually dropped, not all files in the dropped folders (this is a
  consequence of the above).

This brings it more in line with other platforms.

The JS code has been refactored for better processing, and the temporary
deletion is now delegated to the display server.

The "persistentDrops" hack has also been dropped in favor of a localized
solution in the project manager.
@Faless

Faless commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

Needs rebase

Rebased 👍

@Repiteo
Repiteo merged commit 2513414 into godotengine:master Sep 24, 2026
20 checks passed
@Repiteo

Repiteo commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants