Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Blocks: Strange additional markup appears for each media block inserted #15862

Closed
jasmussen opened this issue May 28, 2019 · 5 comments
Closed
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@jasmussen
Copy link
Contributor

jasmussen commented May 28, 2019

Additional, strange, markup is generated when you insert a Cover block, an Image block, or a Media & Text block:

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

Two of these get inserted for each instance of a media block inserted. GIF:

bug

To reproduce

  1. Open the web inspector, scroll to the bottom of the DOM to keep an eye on markup that appears
  2. Insert a block that leverages Media, such as Image or Cover or Media & Text.
  3. Observe how additional markup is created, each time you insert another of these.
  4. If you copy and paste a Cover block in place, you will just create more and more of this dummy markup.

Expected behavior
The extra markup may serve a purpose that I'm unaware of, but there certainly doesn't need to be more than one such button.

Additional context

This was tested on a Mac and reproduced in both Firefox, Safari and Chrome, with or without extensions. This is latest master.

@jasmussen jasmussen added [Type] Bug An existing feature does not function as intended [Feature] Media Anything that impacts the experience of managing media [Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block labels May 28, 2019
@jasmussen
Copy link
Contributor Author

@gziolo Do you have bandwidth to help me investigate what's going on here? It seems the issue is especially visible with lots of placeholders:

Screenshot 2020-02-03 at 11 21 37

In that it's a harmless bug it's not urgent. But I kind of feel like it's a symptom of an underlying issue.

@gziolo
Copy link
Member

gziolo commented Feb 3, 2020

Try again with the following patch applied:

diff --git a/packages/media-utils/src/components/media-upload/index.js b/packages/media-utils/src/components/media-upload/index.js
index 160e2707e..d78e608f8 100644
--- a/packages/media-utils/src/components/media-upload/index.js
+++ b/packages/media-utils/src/components/media-upload/index.js
@@ -137,7 +137,7 @@ class MediaUpload extends Component {
 		this.onClose = this.onClose.bind( this );
 
 		if ( gallery ) {
-			this.buildAndSetGalleryFrame();
+			// this.buildAndSetGalleryFrame();
 		} else {
 			const frameConfig = {
 				title,
@@ -147,18 +147,18 @@ class MediaUpload extends Component {
 				frameConfig.library = { type: allowedTypes };
 			}
 
-			this.frame = wp.media( frameConfig );
+			// this.frame = wp.media( frameConfig );
 		}
 
 		if ( modalClass ) {
-			this.frame.$el.addClass( modalClass );
+			// this.frame.$el.addClass( modalClass );
 		}
 
 		if ( unstableFeaturedImageFlow ) {
-			this.buildAndSetFeatureImageFrame();
+			// this.buildAndSetFeatureImageFrame();
 		}
 
-		this.initializeListeners();
+		// this.initializeListeners();
 	}
 
 	initializeListeners() {

It looks like it's coming from wp.media call, so we would have to improve it inside WordPress core.

@gziolo gziolo added the [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. label Feb 3, 2020
@paaljoachim
Copy link
Contributor

Is this issue still valid?
@gziolo
Thanks!

@jasmussen
Copy link
Contributor Author

It's still an issue:

bug

I'll update the title and steps to make it easier to reproduce.

@jasmussen jasmussen changed the title Media Blocks: Strange additional markup appears when editing a reusable block Media Blocks: Strange additional markup appears for each media block inserted Feb 10, 2021
@Mamaduka
Copy link
Member

I think this is a duplicate of #9184.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

4 participants