Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/js/_enqueues/wp/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,33 @@ jQuery( function($) {
* @return {void}
*/
window.quickPressLoad = function() {
var act = $('#quickpost-action'), t;
var act = $( '#quickpost-action' ), t = $( '#quick-press' ), titleInput, contentInput;
Copy link
Copy Markdown
Member

@westonruter westonruter Mar 29, 2026

Choose a reason for hiding this comment

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

Aside: At some point we should rename the t and act variables to be more useful!


// Enable the submit buttons.
$( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );

t = $('#quick-press').on( 'submit', function( e ) {
titleInput = t.find( '#title' );
contentInput = t.find( '#content' );

function validateAtLeastOne() {
var isFilled = titleInput.val().trim() || contentInput.val().trim(),
message = isFilled ? '' : wp.i18n.__( 'You must provide at least the title or the content.' );
titleInput[0].setCustomValidity( message );
contentInput[0].setCustomValidity( message );
}

t.on( 'input', validateAtLeastOne );

t.on( 'submit', function( e ) {
e.preventDefault();

// Don't submit if both the title and content are empty.
validateAtLeastOne();
if ( ! e.target.checkValidity() ) {
e.target.reportValidity();
return;
}

// Show a spinner.
$('#dashboard_quick_press #publishing-action .spinner').show();

Expand Down Expand Up @@ -180,7 +199,7 @@ jQuery( function($) {
// Change the QuickPost action to the publish value.
$('#publish').on( 'click', function() { act.val( 'post-quickpress-publish' ); } );

$('#quick-press').on( 'click focusin', function() {
t.on( 'click focusin', function() {
wpActiveEditor = 'content';
});

Expand Down
Loading