Skip to content

Fix plugin .zip drop routing to Media Library uploader#256

Merged
epeicher merged 1 commit into
trunkfrom
fix/os-file-drop-respects-inner-handlers
May 20, 2026
Merged

Fix plugin .zip drop routing to Media Library uploader#256
epeicher merged 1 commit into
trunkfrom
fix/os-file-drop-respects-inner-handlers

Conversation

@epeicher

@epeicher epeicher commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Dropping a .zip onto the Plugins → Upload Plugin dropzone opened the Media Library uploader on top of the install dialog instead of installing the plugin. The OS-file-drop manager (added in 0.30.0) listens at the window level; the dropzone's preventDefault call wasn't enough to stop the event from bubbling and being re-processed as a media upload.

What changed

  • src/os-file-drop/manager.tsonDrop and onDragOver bail out when ev.defaultPrevented is true. That's the standard signal that a closer handler has taken ownership of the file, so the window-level manager yields. This generalises to any nested drop zone, current or future.
  • src/plugins-window/upload-dialog.ts — the dropzone's drag/drop listeners call stopPropagation() so the drop doesn't bubble to the Plugins browse-view body handler (which would otherwise open a second install dialog under the modal). The dialog's overlay also swallows stray drops outside the dropzone, matching modal semantics.
  • tests/vitest/os-file-drop-manager.test.ts — new test for the defaultPrevented skip path; afterEach now disposes any mounted manager so the window-level sentinel doesn't leak across tests.

Test plan

  • npm run build clean
  • npm run lint clean
  • ./node_modules/.bin/tsc --noEmit clean
  • npm run test:js — 1465 tests pass (one new)
  • Manual: drop a .zip onto the Upload Plugin dropzone → installs the plugin, no Media Library dialog
  • Manual: drop a .zip onto the dimmed overlay area outside the dropzone → nothing happens (modal swallows it)
  • Manual: drop an image on the desktop wallpaper → Media Library uploader still appears (no regression)
Open WordPress Playground Preview

The OS-file-drop manager (added in 0.30.0) listens at the window
level. When a user drops a .zip onto the Plugins → Upload Plugin
dropzone, the inner handler called preventDefault but the event
still bubbled, so the manager processed the file too and opened
the Media Library uploader on top of the install dialog.

Two fixes:

- The drop manager now bails out of onDrop / onDragOver when
  ev.defaultPrevented is true. defaultPrevented is the standard
  signal that a closer handler has taken ownership of the file,
  so the manager yields. Generalises to any nested drop zone.

- The plugin upload dialog's dropzone calls stopPropagation on
  drag/drop, and the dialog's modal overlay swallows stray drops
  outside the dropzone. Without this, a drop on the dropzone
  also fires the browse-view body handler and opens a second
  install dialog underneath.
@epeicher epeicher enabled auto-merge (squash) May 20, 2026 12:38
@github-actions

Copy link
Copy Markdown
Contributor

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@epeicher epeicher merged commit 46b0306 into trunk May 20, 2026
5 checks passed
@epeicher epeicher deleted the fix/os-file-drop-respects-inner-handlers branch May 20, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant