[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 07:37:20 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:
--------------------------+------------------------------

Comment (by talldanwp):

 So I did some digging and this is happening because whenever a
 MediaUploader is displayed in the editor, wp.media is initialised:
 https://github.com/WordPress/gutenberg/blob/a59a5d9ab761bb2e0ee37eb67aab96d7f3dcf91b/packages
 /media-utils/src/components/media-upload/index.js#L150

 and when that initialisation happens, a new button is appended to the body
 element:
 https://github.com/WordPress/wordpress-
 develop/blob/3dd39ffecea808afe86b8071331551d9d5e8cf89/src/js/media/views/uploader/window.js#L30

 In #39305 @afercia mentions this button is used by another view
 UploaderInline, that detaches one of the buttons when the media uploader
 is opened, and that looks like it's still the case.

 I'm not clear on why this behaviour exists, so I feel uncomfortable
 modifying this code. Why does the button get appended to the body first?
 That's what I'd love to know if anyone has an idea!

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


More information about the wp-trac mailing list