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

Gutenberg: Don't save empty posts #14329

Merged
merged 6 commits into from
Jun 26, 2020

Conversation

SergioEstevao
Copy link
Contributor

@SergioEstevao SergioEstevao commented Jun 16, 2020

Fixes wordpress-mobile/gutenberg-mobile#369

While creating this PR I noticed the following:

  • Gutenberg JS doesn't send auto-save messages when the post is empty, this can cause some sync problems with the status of the Publish button ( being active when it shouldn't). Update: I proposed a fix for this issue in this GB PR: Ensure that the autosave happens on empty posts in the native apps. WordPress/gutenberg#23233, if you want to test with this active start Metro using this branch: Ensure that empty posts are not published gutenberg-mobile#2393
  • I also found some issue where the message sent from GB, has the variable hasChanges set to false when there is changes, this is also confusing the status of the Navigation Publish/Update button, thinking that the post has no changes when it has changes.
  • To make sure the post is never published empty I add a failsafe before the Publish action happens.

To test:

  • Create a new post/page on the editor
  • Write some content (title or post content)
  • Check that the publish button is enabled
  • Delete all content from title and content
  • If the Publish button is enabled, press Publish
  • Check that an alert shows up explaining that an empty post/page cannot be published
  • Now add a single image block and don't write any text.
  • Check that you can publish

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Show an alert if a post or page are empty.
GB can send this HTML when it only has a placeholder paragraph
with no content at all.
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jun 16, 2020

You can trigger an installable build for these changes by visiting CircleCI here.

@SergioEstevao SergioEstevao changed the title Gutenberg/dont save emtpy posts Gutenberg: Don't save empty posts Jun 16, 2020
@SergioEstevao SergioEstevao added the Gutenberg Editing and display of Gutenberg blocks. label Jun 16, 2020
@SergioEstevao SergioEstevao added this to the 15.2 milestone Jun 16, 2020
@SergioEstevao SergioEstevao requested a review from etoledom June 16, 2020 14:13
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jun 16, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

Base automatically changed from gutenberg/implement_word_count to develop June 17, 2020 09:40
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working good as described 🎉

Added a few comments on code. One alternative idea to check if the content is empty.
Let me know what do you think 👍

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As agreed on #14329 (comment), let's merge this to solve the main issue. Then we can improve the logic on a next PR.

Still let's wait for a ✅ on the text by @iamthomasbishop ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make sure an empty draft can't be published
2 participants