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

wp-block paragraph renders empty <p> element if it has no content #24373

Closed
StudioRATATA opened this issue Aug 5, 2020 · 1 comment
Closed

Comments

@StudioRATATA
Copy link

StudioRATATA commented Aug 5, 2020

Hey all,

This is new to me, so I hope I report this right.

  • The gutenberg block paragraph renders an empty <p> element if it has no content.
  • Would it be possible to save it conditionally?

If you change file: https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/paragraph/save.js

And change line 19/26

From:

        return (
		<RichText.Content
			tagName="p"
			className={ className ? className : undefined }
			value={ content }
			dir={ direction }
		/>
	);

To:

         return (
		{content &&
                <RichText.Content
			tagName="p"
			className={ className ? className : undefined }
			value={ content }
			dir={ direction }
		/>}
	);

It would only save if it has content to save, right? So, if no content, no p element.

@skorasaurus
Copy link
Member

Thank you for reporting; this has already been reported at #18297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants