WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.19k forks source link

WP 6.7RC-1: wp.mediaUtils.uploadMedia no longer returns Promise #66551

Open elzadj opened 4 days ago

elzadj commented 4 days ago

Description

Hi all!

We were testing our plugin on WordPress 6.7RC-1, and noticed that our media uploader no longer works. Managed to track it to the differences in wp.mediaUtils.uploadMedia between 6.6.2 and 6.7RC-1.

We use this simple code for tests (based on the readme ):

wp.mediaUtils.uploadMedia( {
    filesList: [ new File( [ 'foo' ], 'foo.txt', { type: 'text/plain' } ) ],
    onFileChange: ( [ fileObj ] ) => console.log( fileObj ),
    onError: console.error,
} );

Compare the results between versions:

6.7RC-1: Image

6.6.2: Image

We can adjust code in our plugin to make it work on both versions, but would be nice to know if this change was intentional. Thanks.

Step-by-step reproduction instructions

  1. Update to 6.7RC-1
  2. Open Gutenberg Editor.
  3. Run
    wp.mediaUtils.uploadMedia( {
    filesList: [ new File( [ 'foo' ], 'foo.txt', { type: 'text/plain' } ) ],
    onFileChange: ( [ fileObj ] ) => console.log( fileObj ),
    onError: console.error,
    } ); 

in your console.

  1. Check the result.

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Please confirm which theme type you used for testing.