Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Fix country defaulting to "Afghan" bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tarhi-saad committed Mar 13, 2023
1 parent 9409cf9 commit e99a18d
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ const Form = ( {
'Country / State',
'woo-gutenberg-products-block'
) }
value={ `${ selectedCountry }${
selectedState &&
states[ selectedCountry ]?.[ selectedState ]
? ':' + selectedState
: ''
}` }
value={ ( () => {
if ( ! selectedState && countryHasStates ) {
return `${ selectedCountry }:${
Object.keys( states[ selectedCountry ] )[ 0 ]
}`;
}

return `${ selectedCountry }${
selectedState &&
states[ selectedCountry ]?.[ selectedState ]
? ':' + selectedState
: ''
}`;
} )() }
onChange={ ( val: string ) => {
const [ country, state = '' ] = val.split( ':' );
setLocationAddressField( 'country' )( country );
Expand Down

0 comments on commit e99a18d

Please sign in to comment.