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

MediaUpload: Hidden Button Element Is Created When Block Rendered #26422

Closed
Copons opened this issue Oct 23, 2020 · 2 comments
Closed

MediaUpload: Hidden Button Element Is Created When Block Rendered #26422

Copons opened this issue Oct 23, 2020 · 2 comments
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended

Comments

@Copons
Copy link
Contributor

Copons commented Oct 23, 2020

Describe the bug

Whenever the Site Logo is rendered, a <button type="button" class="browser" style="display: none;"></button> element is added to the DOM, right before </body>.

cc @scruffian

To reproduce
Steps to reproduce the behavior:

  1. Create a new post, and open the browser's inspection tool; scroll to the bottom to observe what happens near </body>.
  2. Insert a Site Logo block.
  3. Look at the browser's inspection tool: you'll see a new hidden button element added to the DOM right before </body>.

This happens whenever the Site Logo block is rendered, for example, try inserting the block and switch to code editor and back to visual (which renders the block again).
In some cases it only creates 1 button, but usually 2 of them.

Expected behavior

I didn't expect to see a hidden button added to the DOM. 😅

Screenshots

The browser's element inspection tool, after adding a few Site Logo blocks to the editor.

Screenshot 2020-10-23 at 14 41 06

Editor version (please complete the following information):

  • Gutenberg plugin on master (9518819)

Desktop:

  • OS: MacOS 10.15.17
  • Browser: Chrome
  • Version: 86
@Copons Copons added [Type] Bug An existing feature does not function as intended [Block] Site Logo Affects the Site Logo Block labels Oct 23, 2020
@ntsekouras ntsekouras added [Feature] Media Anything that impacts the experience of managing media and removed [Block] Site Logo Affects the Site Logo Block [Feature] Full Site Editing labels Jan 5, 2021
@ntsekouras
Copy link
Contributor

After debugging I found out that these buttons are created from core here: https://github.com/WordPress/WordPress/blob/972c42288a1078d691a1f47239ae26fdd3117ad1/wp-includes/js/media-views.js#L5020

This affects all blocks/components that use the MediaUpload component, like `Image, Cover etc... The created buttons seem to be important for the upload process (I deleted them in dom and it wasn't working) but I didn't go any deeper.

I'm not sure if there is a bug here... Probably someone could look why and prevent creating these blocks in every render.
You can test it just by opening the Page/Post Setting in Inspector Controls, which load the component for the featured image.

@ntsekouras ntsekouras changed the title Site Logo: Hidden Button Element Is Created When Block Rendered MediaUpload: Hidden Button Element Is Created When Block Rendered Jan 5, 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
[Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants