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:
Thomas Roberts 2024-01-18 04:33:50 -08:00 committed by GitHub
parent 91d0e16151
commit bf61e57ce4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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 ),
} );
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Ensure the email field ID remains as `email` in the Checkout block.