Merge pull request #24301 from woocommerce/fix/23870

Fix/23870
This commit is contained in:
Gerhard Potgieter 2019-08-02 14:56:52 +02:00 committed by GitHub
commit daa95c291f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -44,9 +44,10 @@ jQuery( function ( $ ) {
country = $this.val(),
$state = $this.parents( 'div.edit_address' ).find( ':input.js_field-state' ),
$parent = $state.parent(),
stateValue = $state.val(),
input_name = $state.attr( 'name' ),
input_id = $state.attr( 'id' ),
value = $this.data( 'woocommerce.stickState-' + country ) ? $this.data( 'woocommerce.stickState-' + country ) : $state.val(),
value = $this.data( 'woocommerce.stickState-' + country ) ? $this.data( 'woocommerce.stickState-' + country ) : stateValue,
placeholder = $state.attr( 'placeholder' ),
$newstate;
@ -73,6 +74,9 @@ jQuery( function ( $ ) {
var $option = $( '<option></option>' )
.prop( 'value', index )
.text( state[ index ] );
if ( index === stateValue ) {
$option.prop( 'selected' );
}
$newstate.append( $option );
} );
@ -87,7 +91,7 @@ jQuery( function ( $ ) {
.prop( 'name', input_name )
.prop( 'placeholder', placeholder )
.addClass( 'js_field-state' )
.val( '' );
.val( stateValue );
$state.replaceWith( $newstate );
}