Don't clear email and phone fields when using separate billing address. (https://github.com/woocommerce/woocommerce-blocks/pull/4162)

* preseve-billing-data

* pluck empty email and phone

* add issue number
This commit is contained in:
Seghir Nadir 2021-05-05 12:59:30 +01:00 committed by GitHub
parent b9db5d4c51
commit 037dc09f62
1 changed files with 9 additions and 3 deletions

View File

@ -87,10 +87,16 @@ export const useCheckoutAddress = () => {
previousBillingData.current = billingData;
setBillingData( shippingAddress );
} else {
const {
// We need to pluck out email and phone from previous billing data because they can be empty, causing the current email and phone to get emptied. See issue #4155
/* eslint-disable no-unused-vars */
email,
phone,
/* eslint-enable no-unused-vars */
...billingAddress
} = previousBillingData.current;
setBillingData( {
...previousBillingData.current,
email: undefined,
phone: undefined,
...billingAddress,
} );
}
currentShippingAsBilling.current = shippingAsBilling;