From bd5f11d51d12fe27362688f59574dfce0746c8b9 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Thu, 4 Jun 2026 13:32:22 +0800 Subject: [PATCH 1/2] fix: reroute file drop to Gutenberg dropzone --- src/admin/js/media-manager/drop-zone.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/admin/js/media-manager/drop-zone.js b/src/admin/js/media-manager/drop-zone.js index f703df4..bb194da 100644 --- a/src/admin/js/media-manager/drop-zone.js +++ b/src/admin/js/media-manager/drop-zone.js @@ -25,6 +25,7 @@ const ALLOWED_LOCATIONS = applyFilters( 'cimo.dropZone.allowedLocations', [ '.editor-styles-wrapper', // Allowed to drop in the block editor when adding new image blocks '.uploader-window', // Allowed to drop in the admin Media > Library grid view '.uploader-editor', // Allowed to drop in the WooCommerce description editor + '.block-library-utils__media-control', // Allowed to drop in the block editor image block media control ] ) // Add event listener to the Media Manager's drop zone @@ -140,7 +141,7 @@ function addDropZoneListenerToMediaManager( targetDocument ) { await saveMetadata( conversionMetadata ) // Find the correct target to dispatch the event to - let target = event.target + let target = event.target.closest( '.components-drop-zone, [data-is-drop-zone="true"]' ) || event.target // This specifically handles the WooCommerce/classic description editor if ( event.target?.closest( '.uploader-editor-content' ) ) { target = event.target.closest( '.uploader-editor-content' ) @@ -154,7 +155,7 @@ function addDropZoneListenerToMediaManager( targetDocument ) { // inside the DropZoneComponent. // // @see https://github.com/WordPress/gutenberg/blob/f8140c4fcc8db2d6078ad76fd433c79df3543860/packages/components/src/drop-zone/index.tsx#L59 - if ( target?.classList.contains( 'components-drop-zone' ) || target?.classList.contains( 'uploader-editor-content' ) ) { + if ( target?.classList.contains( 'components-drop-zone' ) || target?.hasAttribute( 'data-is-drop-zone' ) || target?.classList.contains( 'uploader-editor-content' ) ) { // Create a drop event with conditional bubbling // Use bubbles: false when in iframe to prevent doubling, but true for main document const isInIframe = targetDocument !== document From 14871a6afe86726d32a3238edb36f38d26303dd4 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Thu, 4 Jun 2026 13:44:28 +0800 Subject: [PATCH 2/2] fix: consistent attribute checking --- src/admin/js/media-manager/drop-zone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin/js/media-manager/drop-zone.js b/src/admin/js/media-manager/drop-zone.js index bb194da..5ab858b 100644 --- a/src/admin/js/media-manager/drop-zone.js +++ b/src/admin/js/media-manager/drop-zone.js @@ -155,7 +155,7 @@ function addDropZoneListenerToMediaManager( targetDocument ) { // inside the DropZoneComponent. // // @see https://github.com/WordPress/gutenberg/blob/f8140c4fcc8db2d6078ad76fd433c79df3543860/packages/components/src/drop-zone/index.tsx#L59 - if ( target?.classList.contains( 'components-drop-zone' ) || target?.hasAttribute( 'data-is-drop-zone' ) || target?.classList.contains( 'uploader-editor-content' ) ) { + if ( target?.classList.contains( 'components-drop-zone' ) || target?.getAttribute( 'data-is-drop-zone' ) === 'true' || target?.classList.contains( 'uploader-editor-content' ) ) { // Create a drop event with conditional bubbling // Use bubbles: false when in iframe to prevent doubling, but true for main document const isInIframe = targetDocument !== document