Ensure "email" field id does not include the section ID (#43734)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
91d0e16151
commit
bf61e57ce4
|
@ -127,6 +127,11 @@ const Form = < T extends AddressFormValues | ContactFormValues >( {
|
|||
...field.attributes,
|
||||
};
|
||||
|
||||
if ( field.key === 'email' ) {
|
||||
fieldProps.id = 'email';
|
||||
fieldProps.errorId = 'billing_email';
|
||||
}
|
||||
|
||||
if ( field.type === 'checkbox' ) {
|
||||
return (
|
||||
<CheckboxControl
|
||||
|
|
|
@ -109,13 +109,20 @@ const getErrorContextFromCode = ( code: string ): string => {
|
|||
};
|
||||
|
||||
/**
|
||||
* Gets appropriate error context from error param name.
|
||||
* Gets appropriate error context from error param name. Also checks the error code to check if it's an email error
|
||||
* (Email is part of the billing address).
|
||||
*/
|
||||
const getErrorContextFromParam = ( param: string ): string | undefined => {
|
||||
const getErrorContextFromParam = (
|
||||
param: string,
|
||||
code: string
|
||||
): string | undefined => {
|
||||
switch ( param ) {
|
||||
case 'invalid_email':
|
||||
return noticeContexts.CONTACT_INFORMATION;
|
||||
case 'billing_address':
|
||||
if ( code === 'invalid_email' ) {
|
||||
return noticeContexts.CONTACT_INFORMATION;
|
||||
}
|
||||
return noticeContexts.BILLING_ADDRESS;
|
||||
case 'shipping_address':
|
||||
return noticeContexts.SHIPPING_ADDRESS;
|
||||
|
@ -168,7 +175,7 @@ const processInvalidParamResponse = (
|
|||
context:
|
||||
context ||
|
||||
additionalFieldContext ||
|
||||
getErrorContextFromParam( param ) ||
|
||||
getErrorContextFromParam( param, code ) ||
|
||||
getErrorContextFromCode( code ),
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Ensure the email field ID remains as `email` in the Checkout block.
|
Loading…
Reference in New Issue