Make WordPress Core

Opened 7 weeks ago

Last modified 6 weeks ago

#64952 new defect (bug)

Dashboard Quick Draft allows creating an empty draft without title or content

Reported by: sumitsingh's profile sumitsingh Owned by:
Milestone: 7.1 Priority: normal
Severity: normal Version: trunk
Component: Administration Keywords: has-screenshots has-patch needs-dev-note
Focuses: accessibility, javascript, administration, coding-standards Cc:

Description

In the WordPress Dashboard, the Quick Draft widget highlights the title field, but it is still possible to create a draft post without entering a title or any content.

Steps to reproduce:

Go to Dashboard → Quick Draft
Leave both Title and Content empty
Click Save Draft

Current result:
A draft post is created even though no title or content was entered.

Expected result:
WordPress should prevent creating an empty draft or require at least a title before saving from Quick Draft.

Why this matters:
This can create accidental empty draft posts and is confusing from a UX perspective.

Attachments (2)

Dashboard ‹ wordpress-1293544-6294750.cloudwaysapps.com — WordPress.mp4 (549.8 KB) - added by sumitsingh 7 weeks ago.
Here are quick recording about empty generating post.
Quick Draft Alert Box for mobile version - 64952.png (63.1 KB) - added by torontodigits 6 weeks ago.
Quick Draft Alert Box for mobile version

Download all attachments as: .zip

Change History (11)

@sumitsingh
7 weeks ago

Here are quick recording about empty generating post.

#1 @gautammkgarg
7 weeks ago

I am facing same issue

PHP: 8.5
WordPress: 7.0-RC1

#2 @huzaifaalmesbah
7 weeks ago

Reproduction Report

Environment

  • WordPress: 7.0-RC1-62111-src
  • PHP: 8.3.30
  • Server: nginx/1.29.6
  • Database: mysqli (Server: 8.4.8 / Client: mysqlnd 8.3.30)
  • Browser: Chrome 146.0.0.0
  • OS: macOS
  • Theme: Twenty Thirteen 4.5
  • MU Plugins: None activated
  • Plugins:
  • Query Monitor 3.20.4
  • Test Reports 1.2.1

Steps taken

  1. Go to Dashboard → Quick Draft
  2. Leave both Title and Content fields empty
  3. Click on Save Draft
  4. 🐞 Bug occurs

Expected behavior

  • WordPress should prevent saving a draft when both title and content are empty, or
  • Require at least a title or content before allowing the draft to be created

This ticket was mentioned in PR #11380 on WordPress/wordpress-develop by @opurockey.


7 weeks ago
#3

  • Keywords has-patch added

Ticket: https://core.trac.wordpress.org/ticket/64952

## Summary

This PR fixes an issue in the WordPress dashboard Quick Draft widget where a draft could be submitted even when both the title and content fields were empty.

The update introduces validation to prevent submission unless at least one of these fields contains input, improving data integrity and user experience.

## Problem

Currently, the Quick Draft form allows users to submit completely empty drafts. This results in unnecessary blank draft entries being created in the database, which can clutter the posts list and create confusion.

Similar inconsistencies with Quick Draft behavior have been observed historically, where drafts may be created without meaningful content due to missing validation.

## Solution

  • Added validation to the Quick Draft submission flow.
  • Prevents form submission when both title and content are empty.
  • Ensures at least one field is filled before allowing draft creation.

Changes

  • Introduced conditional checks before submitting the Quick Draft form.
  • Updated relevant JavaScript/PHP logic to block empty submissions.

## Testing Steps

  • Go to WordPress Dashboard → Quick Draft widget.
  • Leave both Title and Content empty.
  • Attempt to submit.
  • Confirm that submission is blocked.
  • Add either a title or content and submit again.
  • Confirm that the draft is successfully created.

#4 @opurockey
7 weeks ago

@sumitsingh From Posts-> Add post, We can't save post if both title and content fields are empty. We can follow the same approach here. I have raised a PR that will prevent submission from quick draft if both fields are empty.

@opurockey commented on PR #11380:


7 weeks ago
#5

@westonruter , Thanks for the suggestions. I’ve addressed the requested improvements and updated the PR accordingly. Please take another look when you have a moment.

@westonruter commented on PR #11380:


7 weeks ago
#6

@OpuRockey An idea came to mind to leverage setCustomValidity so that an error message can be displayed in addition to focusing on the field. I added this in 899ed5b:

https://github.com/user-attachments/assets/306fc4c5-9ef6-4b11-a5dc-bb35d8ffe9cc

This provides the same result as you had, but with added accessibility and improved user experience.

@westonruter commented on PR #11380:


7 weeks ago
#7

  • Updated relevant JavaScript/PHP logic to block empty submissions.

It doesn't seem any PHP logic was added to block empty submissions?

#8 @SergeyBiryukov
7 weeks ago

  • Milestone changed from Awaiting Review to 7.1

#9 @torontodigits
6 weeks ago

  • Keywords needs-dev-note added

@westonruter we've tested alert box in mobile & it looks a bit large as it has same font size that is for desktop & in our opnion font size should be less as compared to desktop by following UX rules.

What's your take on mobile version of alert box font size?

@torontodigits
6 weeks ago

Quick Draft Alert Box for mobile version

Note: See TracTickets for help on using tickets.