Skip to content

Commit

Permalink
fix: Reset state selector value
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Feb 1, 2022
1 parent 9ba8a71 commit 90fdb3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/AddressStateSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ const AddressStateSelector: FunctionComponent<AddressStateSelectorProps> = (
billingCountryCode,
countryCode !== billingCountryCode,
].every(Boolean)
if (changeBillingCountry && !isValidState(val, billingCountryCode)) {
if (
changeBillingCountry &&
!isValidState(val, billingCountryCode) &&
!isEmptyStates(billingCountryCode)
) {
billingAddress.resetField && billingAddress.resetField(name)
setVal('')
}
Expand All @@ -72,7 +76,11 @@ const AddressStateSelector: FunctionComponent<AddressStateSelectorProps> = (
shippingCountryCode,
countryCode !== shippingCountryCode,
].every(Boolean)
if (changeShippingCountry && !isValidState(val, shippingCountryCode)) {
if (
changeShippingCountry &&
!isValidState(val, shippingCountryCode) &&
!isEmptyStates(shippingCountryCode)
) {
shippingAddress.resetField && shippingAddress.resetField(name)
setVal('')
}
Expand Down

0 comments on commit 90fdb3f

Please sign in to comment.