Fix broken dynamic address fields dependent on locale for selected country. (https://github.com/woocommerce/woocommerce-blocks/pull/2547)

* add missing dependency

* Don’t include all defaultAddressFields in address field config
This commit is contained in:
Darren Ethier 2020-05-25 07:00:26 -04:00 committed by GitHub
parent a5bca5708c
commit ce1e334c56
2 changed files with 10 additions and 6 deletions

View File

@ -94,6 +94,7 @@ const AddressForm = ( {
countryValidationError,
setValidationErrors,
clearValidationError,
type,
] );
id = id || instanceId;

View File

@ -136,9 +136,8 @@ const Checkout = ( { attributes, scrollToTop } ) => {
setShippingAsBilling,
showBillingFields,
} = useCheckoutAddress();
const addressFields = useMemo( () => {
const addressFieldsConfig = useMemo( () => {
return {
...defaultAddressFields,
company: {
...defaultAddressFields.company,
hidden: ! attributes.showCompanyField,
@ -253,8 +252,10 @@ const Checkout = ( { attributes, scrollToTop } ) => {
id="shipping"
onChange={ setShippingFields }
values={ shippingFields }
fields={ Object.keys( addressFields ) }
fieldConfig={ addressFields }
fields={ Object.keys(
defaultAddressFields
) }
fieldConfig={ addressFieldsConfig }
/>
{ attributes.showPhoneField && (
<ValidatedTextInput
@ -311,8 +312,10 @@ const Checkout = ( { attributes, scrollToTop } ) => {
onChange={ setBillingFields }
type="billing"
values={ billingFields }
fields={ Object.keys( addressFields ) }
fieldConfig={ addressFields }
fields={ Object.keys(
defaultAddressFields
) }
fieldConfig={ addressFieldsConfig }
/>
</FormStep>
) }