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

Preformatted blocks are losing whitespace. #6917

Closed
diegoreymendez opened this issue May 23, 2018 · 13 comments
Closed

Preformatted blocks are losing whitespace. #6917

diegoreymendez opened this issue May 23, 2018 · 13 comments
Assignees
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended

Comments

@diegoreymendez
Copy link
Contributor

diegoreymendez commented May 23, 2018

Describe the bug

Preformatted blocks are not really working as expected. They're losing whitespace when converting from visual to HTML and back.

Gutenberg v2.9.2

To Reproduce

Steps to reproduce the behavior:

  1. Add a "Preformatted" block
  2. Write some text with extensive usage of whitespace. For example
This is some text
     in two lines        yes two lines
  1. Save the post.
  2. Exit and reopen it.

Expected behavior

The whitespace should be maintained.

Screenshots

screen shot 2018-05-23 at 12 24 51

screen shot 2018-05-23 at 12 25 24

Desktop (please complete the following information):

  • OS: OS X
  • Browser Safari
  • Version 11.1 (13605.1.33.1.4)
@danielbachhuber
Copy link
Member

Hi @diegoreymendez,

Thanks for the detailed report! I can't reproduce this issue in Safari Version 11.1 (13605.1.33.1.4) on master or in Gutenberg v2.9.2:

pretext

Are you running any plugins that might impact what's being saved? Can you debug further to see if you can track down any more details?

@danielbachhuber danielbachhuber added the [Status] Needs More Info Follow-up required in order to be actionable. label May 25, 2018
@diegoreymendez
Copy link
Contributor Author

In the following example, the plugins I have are:

Gutenberg 2.9.2
Jetpack 6.1.1

testinggutenberg

@danielbachhuber
Copy link
Member

Can you try disabling Jetpack and seeing if he problem reproduces with Jetpack disabled?

@danielbachhuber
Copy link
Member

@diegoreymendez Were you able to track this down?

@diegoreymendez
Copy link
Contributor Author

@danielbachhuber - I'm getting the same issue with Jetpack disabled. It's not properly rendering whitespace when following the steps from my GIF above.

@danielbachhuber
Copy link
Member

@diegoreymendez Odd. Could it be a browser extension?

@diegoreymendez
Copy link
Contributor Author

@danielbachhuber - This is what I see without WP Plugins (other than Gutenberg), and without Safari extensions (the only one I had was 1Password, and I disabled it for this).

gutenproblems

I noticed you tested this doing some form of page reload... can you try switching to HTML mode and back to see if you can reproduce the same behavior?

@danielbachhuber danielbachhuber added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks and removed [Status] Needs More Info Follow-up required in order to be actionable. labels Jun 4, 2018
@danielbachhuber
Copy link
Member

can you try switching to HTML mode and back to see if you can reproduce the same behavior?

Yes, I can reproduce your bug report now. Thanks for diligently tracking down reproduction steps.

@danielbachhuber danielbachhuber added this to the WordPress 5.0 milestone Jun 4, 2018
@danielbachhuber danielbachhuber self-assigned this Jun 4, 2018
@rosswintle
Copy link
Contributor

I've found what I think is the same thing. It occurs when duplicating blocks and when saving a post and re-loading.

This is:

  • Chrome 67
  • MacOS High Sierra 10.13.5
  • WP 4.9.6
  • Gutenberg 3.0.1
  • Lots of plugins (this is on my live blog site)

Video: https://cl.ly/2C0d2w2W291P

Looks like you've managed to replicate but do you want me to try and make this happen in a simpler setup?

@danielbachhuber
Copy link
Member

@rosswintle I think this part of your video describes the reproduction steps well:

preformatted

Notably:

  1. Create a pre-formatted block.
  2. Write some indented text into the block.
  3. Duplicate the block.
  4. Notice that the text in the duplicated block has lost its formatting.

I wasn't able to reproduce the aforementioned steps with the paragraph block, so it seems specific to the pre-formatted block.

I don't know the transformation code well enough to know how to debug this yet though.

@iseulde @jorgefilipecosta @aduth Any tips for debugging?

@aduth
Copy link
Member

aduth commented Jun 25, 2018

I expect this is likely related to / duplicate of #4456 , caused by block serializer's beautification removing excess whitespace.

Though I might have thought js-beautify would at least ignore text within pre tags. Seems it's being respected okay at least for the original block?

I wasn't able to reproduce the aforementioned steps with the paragraph block, so it seems specific to the pre-formatted block.

It could be that TinyMCE is inserting whitespace as   entities, whereas the Preformatted block is using a simple textarea field.

@danielbachhuber
Copy link
Member

Some good examples in #7836

@danielbachhuber
Copy link
Member

This is fixed by #7892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants