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

Centered button identified as "modified externally" #3426

Closed
jasmussen opened this issue Nov 10, 2017 · 9 comments · Fixed by #3455
Closed

Centered button identified as "modified externally" #3426

jasmussen opened this issue Nov 10, 2017 · 9 comments · Fixed by #3455
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@jasmussen
Copy link
Contributor

Issue Overview

A centered button is misreported as having been modified externally, offering an overwrite.

Steps to Reproduce (for bugs)

  1. Insert a button, add a label
  2. Save
  3. Center button, save
  4. Reload

Now it identifies the button as modified externally, and if you click "overwrite", it will left align the button.

@jasmussen jasmussen added the [Type] Bug An existing feature does not function as intended label Nov 10, 2017
@jasmussen
Copy link
Contributor Author

From @gziolo: it is likely that it complains because no href is set.

@gziolo gziolo added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Nov 10, 2017
@gziolo
Copy link
Member

gziolo commented Nov 10, 2017

It looks like something else causes it, when you don't use align it works perfectly fine. Once you pick any alignment option it breaks.

@youknowriad
Copy link
Contributor

youknowriad commented Nov 10, 2017

Looks like a bug backend side (maybe in the PHP block parser). I think all comment blocks are stripped server-side which may break several blocks. For example, applying a color to a text block. Seems to be a recent regression

Edit: It's probably a regression introduced by #2806

@youknowriad youknowriad added the [Priority] High Used to indicate top priority items that need quick attention label Nov 10, 2017
@mcsf
Copy link
Contributor

mcsf commented Nov 12, 2017

Edit: It's probably a regression introduced by #2806

I believe #2806 only better surfaced a regression actually introduced by #2743.

Edit: Spoke too soon. It seems that something in the way that gutenberg_parse_blocks is called from within gutenberg_wpautop_block_content/wp_insert_post_data leads to missing attributes in the parse tree, but not when calling the parser in other circumstances (e.g. standalone PHP test).

@ephox-mogran
Copy link
Contributor

ephox-mogran commented Nov 13, 2017

I haven't really looked at the back-end yet, so just thought I'd ask the question:

This content is sent to the server:

content: "<!-- wp:button {"align":"right"} -->↵<div class="wp-block-button alignright"><a>Button</a></div>↵<!-- /wp:button -->"

This is the response:

content.raw: <!-- wp:core/button -->↵<div class="wp-block-button alignright"><a>Button</a></div>↵<!-- /wp:core/button -->

Is this expected? I assume the missing {"align":"right"} information in the comment is causing the problem? That's what you're referring to @youknowriad ?

@mcsf
Copy link
Contributor

mcsf commented Nov 13, 2017

When called from wp_insert_post_data, the raw content includes backslashes in block attributes JSON:

<!-- wp:core/button {\"align\":\"center\"} -->
<div class=\"wp-block-button aligncenter\"><a>Label</a></div>
<!-- /wp:core/button -->

<!-- wp:core/latest-posts {\"displayPostDate\":true} /-->

Stripping them out fixes the issue for me.

@gziolo
Copy link
Member

gziolo commented Nov 13, 2017

Questions unrelated to this PR, @mtias & @pento, is it expected to have wp:button on the client side and wp:core/button on the server side?

@mcsf
Copy link
Contributor

mcsf commented Nov 13, 2017

@gziolo, do you mean #2950?

@gziolo
Copy link
Member

gziolo commented Nov 13, 2017

@mcsf, yes, this one.

mcsf added a commit that referenced this issue Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants