From 09bbfae80a01b13dbc5aa036b50832a96e4cc345 Mon Sep 17 00:00:00 2001 From: ArkaPrabhaChowdhury Date: Thu, 6 Aug 2026 13:26:31 +0530 Subject: [PATCH 1/2] Prevent duplicate Quick Edit saves --- src/js/_enqueues/admin/inline-edit-post.js | 17 ++++++++++++++++- src/js/_enqueues/admin/inline-edit-tax.js | 15 ++++++++++++++- tests/qunit/index.html | 4 ++++ tests/qunit/wp-admin/js/inline-edit.js | 19 +++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/qunit/wp-admin/js/inline-edit.js diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 36ffaf18ef778..390a41f51f917 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -26,6 +26,13 @@ window.wp = window.wp || {}; window.inlineEditPost = { + /** + * Whether a save request is active. + * + * @type {boolean} + */ + saving: false, + /** * Initializes the inline and bulk post editor. * @@ -488,6 +495,11 @@ window.wp = window.wp || {}; save : function(id) { var params, fields, page = $('.post_status_page').val() || ''; + if ( this.saving ) { + return false; + } + this.saving = true; + if ( typeof(id) === 'object' ) { id = this.getId(id); } @@ -536,7 +548,10 @@ window.wp = window.wp || {}; wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) ); } }, - 'html'); + 'html' + ).always( function() { + inlineEditPost.saving = false; + } ); // Prevent submitting the form when pressing Enter on a focused field. return false; diff --git a/src/js/_enqueues/admin/inline-edit-tax.js b/src/js/_enqueues/admin/inline-edit-tax.js index 86e3498cd1eac..ddc91b49036ef 100644 --- a/src/js/_enqueues/admin/inline-edit-tax.js +++ b/src/js/_enqueues/admin/inline-edit-tax.js @@ -20,6 +20,12 @@ window.wp = window.wp || {}; ( function( $, wp ) { window.inlineEditTax = { + /** + * Whether a save request is active. + * + * @type {boolean} + */ + saving: false, /** * Initializes the inline taxonomy editor by adding event handlers to be able to @@ -167,6 +173,11 @@ window.inlineEditTax = { save : function(id) { var params, fields, tax = $('input[name="taxonomy"]').val() || ''; + if ( this.saving ) { + return false; + } + this.saving = true; + // Makes sure we can pass an HTMLElement as the ID. if( typeof(id) === 'object' ) { id = this.getId(id); @@ -242,7 +253,9 @@ window.inlineEditTax = { wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) ); } } - ); + ).always( function() { + inlineEditTax.saving = false; + } ); // Prevent submitting the form when pressing Enter on a focused field. return false; diff --git a/tests/qunit/index.html b/tests/qunit/index.html index d0e81acedb502..6dee28ce4b62d 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -76,6 +76,7 @@
+
@@ -90,6 +91,8 @@ + + @@ -147,6 +150,7 @@ + diff --git a/tests/qunit/wp-admin/js/inline-edit.js b/tests/qunit/wp-admin/js/inline-edit.js new file mode 100644 index 0000000000000..3f968e28b4ce3 --- /dev/null +++ b/tests/qunit/wp-admin/js/inline-edit.js @@ -0,0 +1,19 @@ +/* global QUnit, inlineEditPost, inlineEditTax */ + +( function() { + 'use strict'; + + QUnit.module( 'wp.inlineEdit' ); + + QUnit.test( 'Duplicate post saves are ignored while a request is active', function( assert ) { + inlineEditPost.saving = true; + assert.strictEqual( inlineEditPost.save( 1 ), false, 'A duplicate post save is ignored.' ); + inlineEditPost.saving = false; + } ); + + QUnit.test( 'Duplicate taxonomy saves are ignored while a request is active', function( assert ) { + inlineEditTax.saving = true; + assert.strictEqual( inlineEditTax.save( 1 ), false, 'A duplicate taxonomy save is ignored.' ); + inlineEditTax.saving = false; + } ); +} )(); From 3e3dcd3e735ed8743e09bd4120f83295e93f1b47 Mon Sep 17 00:00:00 2001 From: ArkaPrabhaChowdhury Date: Fri, 7 Aug 2026 15:51:30 +0530 Subject: [PATCH 2/2] Document inline edit save state --- src/js/_enqueues/admin/inline-edit-post.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 390a41f51f917..698636fb039cd 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -20,6 +20,7 @@ window.wp = window.wp || {}; * * @property {string} type The type of inline editor. * @property {string} what The prefix before the post ID. + * @property {boolean} saving Whether a save request is active. * */ ( function( $, wp ) {