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

Multi-line Code blocks from WP 5.5 lose line breaks when GB active #26301

Closed
westonruter opened this issue Oct 19, 2020 · 4 comments
Closed

Multi-line Code blocks from WP 5.5 lose line breaks when GB active #26301

westonruter opened this issue Oct 19, 2020 · 4 comments
Labels
[Block] Code Affects the Code Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@westonruter
Copy link
Member

Given an Code block with the content:

<!-- wp:code -->
<pre class="wp-block-code"><code>if ( a === b ) {
    doSomething();
}</code></pre>
<!-- /wp:code -->

In WP 5.5 when Gutenberg is inactive, this is rendered in the editor as follows:

image

When activating Gutenberg, however, this gets rendered in the editor as:

image

This appears to be a regression introduced in v9.1 with allowing HTML editing and rich text in the Code block: #24689, since the block's content attribute changed from a text source to an html source. This is in spite of the fact that the code is still in a pre.

If I try recreating this Code block with Gutenberg active, then I get this saved content:

<!-- wp:code -->
<pre class="wp-block-code"><code>if ( a === b ) {<br>    doSomething();<br>}</code></pre>
<!-- /wp:code -->

Note that <br> tags are now needed to represent line breaks instead of newline characters.

Is there a block deprecation function missing here?

cc @ellatrix @mkaz

@westonruter westonruter added [Block] Code Affects the Code Block [Type] Bug An existing feature does not function as intended labels Oct 19, 2020
@ZebulanStanphill ZebulanStanphill added [Priority] High Used to indicate top priority items that need quick attention [Type] Regression Related to a regression in the latest release labels Oct 19, 2020
@getdave
Copy link
Contributor

getdave commented Oct 20, 2020

I can confirm this is happening on my personal site as well.

@joyously
Copy link

I was testing something else, but saw this reformatting happening in the Classic block as well, which I don't think was happening before.

@talldan
Copy link
Contributor

talldan commented Oct 22, 2020

#26347 seems to fix a similar issue with indentation.

@tellthemachines
Copy link
Contributor

Closing as fixed by #26347.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Code Affects the Code Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

6 participants