Merge pull request #32589 from woocommerce/issue-31347

Enable "Save changes" for variations on the admin when a textfield receives input
This commit is contained in:
Barry Hughes 2022-04-12 08:05:47 -07:00 committed by GitHub
commit 84392cfbf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Enable the "Save changes" button within the variations panel when a textfield receives input.

View File

@ -350,7 +350,7 @@ jQuery( function( $ ) {
.on( 'click','.downloadable_files a.delete', this.input_changed );
$( document.body )
.on( 'change', '#variable_product_options .woocommerce_variations :input', this.input_changed )
.on( 'change input', '#variable_product_options .woocommerce_variations :input', this.input_changed )
.on( 'change', '.variations-defaults select', this.defaults_changed );
var postForm = $( 'form#post' );
@ -705,13 +705,18 @@ jQuery( function( $ ) {
/**
* Add new class when have changes in some input
*/
input_changed: function() {
input_changed: function( event ) {
$( this )
.closest( '.woocommerce_variation' )
.addClass( 'variation-needs-update' );
$( 'button.cancel-variation-changes, button.save-variation-changes' ).prop( 'disabled', false );
// Do not trigger 'woocommerce_variations_input_changed' for 'input' events for backwards compat.
if ( 'input' === event.type && $( this ).is( ':text' ) ) {
return;
}
$( '#variable_product_options' ).trigger( 'woocommerce_variations_input_changed' );
},