Prevent empty Quick Draft submissions from WordPress dashboard#11380
Prevent empty Quick Draft submissions from WordPress dashboard#11380OpuRockey wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| e.preventDefault(); | ||
|
|
||
| // Don't submit if both the title and content are empty. | ||
| if ( '' === t.find('#title').val() && '' === t.find('#content').val() ) { |
There was a problem hiding this comment.
Nit: Additional spaces needed in the arg passed the find() method. Might as well put each on their own line to make it easier to read:
| if ( '' === t.find('#title').val() && '' === t.find('#content').val() ) { | |
| if ( | |
| '' === t.find( '#title' ).val() && | |
| '' === t.find( '#content' ).val() | |
| ) { |
|
|
||
| // Don't submit if both the title and content are empty. | ||
| if ( '' === t.find('#title').val() && '' === t.find('#content').val() ) { | ||
| $('#title').trigger( 'focus' ); |
There was a problem hiding this comment.
| $('#title').trigger( 'focus' ); | |
| $( '#title' ).trigger( 'focus' ); |
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
Changes
Testing Steps