[wp-trac] [WordPress Trac] #49431: Media uploader window leaves behind orphan button element in Block Editor

WordPress Trac noreply at wordpress.org
Fri Feb 14 08:23:22 UTC 2020


#49431: Media uploader window leaves behind orphan button element in Block Editor
--------------------------+------------------------------
 Reporter:  talldanwp     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  5.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  javascript
--------------------------+------------------------------
Changes (by afercia):

 * focuses:   => javascript


Comment:

 @talldanwp correct. However, the core implementation makes sure to
 initialize wp.media just once and reuse the existing one if already
 initialized. Thus, in the Classic Editor there will be just one button
 element.

 Instead, the Gutenberg implementation initializes a new wp.media each
 time, ending up in multiple buttons appended to the body.

 {{{
 <button type="button" class="browser" style="display: none;"></button>
 <button type="button" class="browser" style="display: none;"></button>
 <button type="button" class="browser" style="display: none;"></button>
 <button type="button" class="browser" style="display: none;"></button>
 }}}

 Additionally, on current trunk:
 - create a post
 - add an image block and do not add an image yet: just keep the block
 "placeholder'
 - inspect the DOM in your browser's dev tools
 - notice two buttons appended to the body
 - add a gallery block
 - notice two more buttons are appended to the body

 This makes me think that there's something that actually runs ''twice''
 each time a media-related block is added. Not ideal from a performance
 perspective as I suspect there are several media objects initialized.

 Noting the initialization issue was already reported somewhere in other
 GitHub issues or Trac tickets and still to be solved.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49431#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list