Make WordPress Core

Opened 22 months ago

Last modified 13 months ago

#62769 new enhancement

Saving Post without Title and Content

Reported by: tristup Owned by:
Priority: normal Milestone: Awaiting Review
Component: Editor Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Hi Team,

While saving the post, I found that the post is saving with the title and content and showing the success message as shown in the given screenshot.

  1. ​https://tinyurl.com/28oxwfk9

By clicking into the View Post, it opens the 404 page, which is not correct either.

I would suggest adding some validation to check if the title should not be blank, or else there might be a proper message. Also, if that post is added, it should show in the post lists.

Thanks
Tristup

Change History (11)

#1 @subrataemfluence
22 months ago

  • Component General → Posts, Post Types
  • Focuses administration added
  • Keywords needs-screenshots 2nd-opinion added
  • Type defect (bug) → enhancement
  • Version → 6.7.1

Hi @tristup
I also think that there should be some validation check, at least for the title. Or, it could be like a Post may not be "published" without a title and can only be saved as a draft.

Also, it would be great if you could share a screenshot of your 404 page.

#2 @tristup
22 months ago

Hi @subrataemfluence ,

Yes, the publish button can be activated once the title is there.

Thanks

#3 @abcd95
22 months ago

  • Keywords needs-screenshots 2nd-opinion removed

Hey @tristup, Welcome to Trac!

I've looked into this and can confirm that this behavior only occurs in the Classic Editor. The core Gutenberg editor actually prevents this scenario by design - it doesn't allow posts to be published without a title and content.

Screenshot of the classic editor -

https://i.postimg.cc/T29VmwTJ/1.jpg

Screenshot of the Gutenberg editor -

https://i.postimg.cc/QC2hVDY9/2.jpg

If you'd like to track or contribute to fixing this issue in the Classic Editor, you can raise it in the plugin's GitHub repository here:
​https://github.com/WordPress/classic-editor

Last edited 20 months ago by abcd95 (previous) (diff)

#4 @niravsherasiya7707
20 months ago

Hello @abcd95,
I looked into this on my end and found that the Gutenberg editor allows publishing a post/page without a title. Could you confirm if this is the expected behavior?

​https://vimeo.com/1053634062/18e8ba7800

#5 @abcd95
20 months ago

Replying to niravsherasiya7707:

Gutenberg editor allows publishing a post/page without a title. Could you confirm if this is the expected behavior?

Thanks, @niravsherasiya7707, for pointing this out. I meant that the Gutenberg editor doesn't allow publishing a post or page without a title and content. If either of these is present, it can be published. I have updated my comment.

#6 @akshat2802
14 months ago

Here is the PR that solves the issue for Classic Editor.
Added JavaScript such that it behaves the same as the Gutenberg Editor. The Publish Button remains disabled until either of the fields (Title or Content) is filled.

PR Link: ​https://github.com/WordPress/classic-editor/pull/226

#7 @akshat2802
14 months ago

  • Keywords has-patch added

#8 follow-ups: @SirLouen
13 months ago

  • Component Posts, Post Types → Editor
  • Focuses administration removed
  • Version 6.7.1

Although there is this classic editor plugin to help switch to classic editor capabilities, I believe that this can be solved in core. A check should be in place in the editor to save and throw the corresponding error.

#9 in reply to: ↑ 8 @subrataemfluence
13 months ago

@SirLouen, I completely agree with you. This check should be built into the core of WordPress

Last edited 13 months ago by subrataemfluence (previous) (diff)

This ticket was mentioned in ​PR #10055 on ​WordPress/wordpress-develop by ​@akshat2802.


13 months ago
#10

This PR solves : https://core.trac.wordpress.org/ticket/62769

Summary
This PR adds logic to disable the "Publish" button in the Classic Editor interface when both the post title and content fields are empty. The button is automatically re-enabled once either field has valid input.

#11 in reply to: ↑ 8 @akshat2802
13 months ago

Replying to SirLouen:

Although there is this classic editor plugin to help switch to classic editor capabilities, I believe that this can be solved in core. A check should be in place in the editor to save and throw the corresponding error.

Thanks, @SirLouen, for the review.
I’ve opened a PR in core that matches the current Gutenberg behaviour: the Publish button remains disabled until there is content either in the post title or body.

PR Link: ​https://github.com/WordPress/wordpress-develop/pull/10055

Last edited 13 months ago by akshat2802 (previous) (diff)
Note: See TracTickets for help on using tickets.