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

Remove empty blocks when saving a Post #9167

Closed
StaggerLeee opened this issue Aug 20, 2018 · 21 comments
Closed

Remove empty blocks when saving a Post #9167

StaggerLeee opened this issue Aug 20, 2018 · 21 comments
Labels
[Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request.

Comments

@StaggerLeee
Copy link

I decided to go for Bug report.

Please, remove empty blocks when saving a Post. What is the point of empty blocks in a Post ?

@TopCheff
Copy link

yo tambien estoy deacuerdo con esto.

gracias!

@youknowriad
Copy link
Contributor

How do you consider a block empty?

@StaggerLeee
Copy link
Author

You know what is empty block.
Inserted and nothing inside touched/added.

If it has real life uses list them here. Because I don't know them.

@youknowriad
Copy link
Contributor

So If I add a "latest posts" block and I don't touch it, it's empty?

@StaggerLeee
Copy link
Author

Listen, have no lust for verbal games. You know what I mean when I say "empty blocks". Stop playing stupid.

@youknowriad
Copy link
Contributor

youknowriad commented Aug 20, 2018

I'm not playing any game here. Sorry if it was misunderstood.

This was just an example, I can think of a lot of use-cases where this description of empty block doesn't work. I think it's impossible to know for sure that we can delete a block in a generic way. Plugins can extend core blocks and make them not empty by default... For these reasons, I think it's adding such behavior is impossible.

@0aveRyan
Copy link
Contributor

Fair points raised here. Empty paragraphs are truly empty without characters. Image blocks are truly empty without an image set.

However, the Latest Posts Block, Spacer block and a few others can be inserted and left alone without being configured.

@StaggerLeee
Copy link
Author

Not in the wildest dreams a plugin can, or may, edit my own content in a block. Specially when there is no content, and no business for a plugin there.
Empty block is block inserted by mistake and no plugin has anything to do with it, add/change content inside. If a plugin wants to change HTML tags, schema, etc....what is usual and often normal, it is still empty block (content).

I am talking about content, not block HTML tags, or CSS design.

Empty (0) X Empty (0) = Empty (0) = Plugin is out of the picture.

@paaljoachim
Copy link
Contributor

Hey Stagger

I think you are likely talking about this:

screen shot 2018-08-20 at 17 05 14

empty-blocks-gutenberg

@StaggerLeee
Copy link
Author

Yes, about this. But not only this. Gallery can be empty and many more. Empty quote block leaves CSS styling on front-page.

All this will later cost much in expensive regex on page load.

@youknowriad
Copy link
Contributor

I don't disagree with the fact that empty blocks (especially paragraphs) would be better if removed, but technically speaking, there's nothing that can allow us to know for sure that a block is really empty.

  • I can imagine a plugin add a server-side rendering to blocks (even if empty) and replace them with something else.
  • I can see people creating image placeholders for other users to fill (templates + content)
  • I can see people changing the placeholder of empty paragraphs for other editors to fill.

While it's annoying to have empty paragraphs in the content, I think it's worse to lose content.

@ZebulanStanphill
Copy link
Member

ZebulanStanphill commented Aug 20, 2018

Technically speaking the empty blocks are not even actually empty. They still contain some HTML:

<p></p>

@youknowriad
Copy link
Contributor

I'm closing as invalid, let's reopen if there's any actionable item we can tackle here

@youknowriad youknowriad added the [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request. label Aug 20, 2018
@StaggerLeee
Copy link
Author

A so, you mean template, and possibly shared, blocks. Now it is legitimate and more clear.

You had it nailed but for some reason decided to change it. When a User clicks outside of empty block you had it so it automatically is removed.

@youknowriad
Copy link
Contributor

The behavior you describe was causing Writing Flow issues and was not consistent. Depending on how you'd create/touch the paragraph, it was removed or not. It was removed in #8706 because the root issue for the existence of this behavior was fixed. (accidentally creating empty paragraphs when clicking the in-between line inserter)

@StaggerLeee
Copy link
Author

StaggerLeee commented Aug 20, 2018

Block revolution is your idea, not mine.

Before in TinyMce I had to use simple regex to remove empty paragraphs. Now they will be much complex and frustrating.
Don't know even if it is possible to target HTML tags this way to remove blocks from display/source code.

@ZebulanStanphill
Copy link
Member

Disclaimer: I am not a WordPress or Gutenberg dev.

@StaggerLeee If you are adding empty paragraphs to your content, I would expect that to be your responsibility to clean up?

Also, there is a CSS selector to style empty elements, so you could make empty <p> elements use display: none, but I think you should probably just clean up your posts and use the Spacer block, Custom HTML block, or CSS classes to add spacing where it is desirable:
https://developer.mozilla.org/en-US/docs/Web/CSS/:empty

@StaggerLeee
Copy link
Author

It is not for me, but for beginners. Those who use WordPress in at least 85% of cases.
It is not about paragraphs, but many other blocks. Paragraphs are not important here.

Still do not get it. Force plugin developers to flag if they influence/force empty blocks, and what block(s).
Gutenberg decides standards, not other way around.
So commended Facebook, and others, script. And it has no clue what is happening server side.

@paaljoachim
Copy link
Contributor

Well all those empty paragraphs sure do not look nice....
#2466

@StaggerLeee
Copy link
Author

Not related to this. Inserter is now very confusing for me. You come to the last block down, and plus icon point to insert a block as second last one.

Not logical for me. If whole philosophy of writing flow is to go down, down, down. Why to go back with block insert.

Maybe I have some script conflict on installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request.
Projects
None yet
Development

No branches or pull requests

6 participants