diff --git a/src/shared-components/field/__snapshots__/test.tsx.snap b/src/shared-components/field/__snapshots__/test.tsx.snap index 0bf35c0ed..7b7fae6b3 100644 --- a/src/shared-components/field/__snapshots__/test.tsx.snap +++ b/src/shared-components/field/__snapshots__/test.tsx.snap @@ -264,6 +264,7 @@ exports[` UI snapshots renders with errorMessage, hintMessage and hideM class="emotion-2 emotion-3" >
UI snapshots renders with errorMessage, hintMessage and hideM style="opacity: 1; max-height: 48px; transition-duration: 350ms; transition-property: max-height, opacity; transition-timing-function: ease-in-out;" type="error" > - - Uh Oh! - - Type again + + + Uh Oh! + + Type again +
diff --git a/src/shared-components/field/index.tsx b/src/shared-components/field/index.tsx index 157d2375a..48767e128 100644 --- a/src/shared-components/field/index.tsx +++ b/src/shared-components/field/index.tsx @@ -79,6 +79,9 @@ export const Field: Field = ({ /> ); + const { id } = inputChild.props as Record<'id', string | undefined>; + const isInvalid = showMessages && messagesType === 'error'; + return ( {!!label && ( @@ -95,11 +98,16 @@ export const Field: Field = ({ {React.cloneElement(inputChild, { disabled, + 'aria-invalid': isInvalid || undefined, })} {!!hintMessage && {hintMessage}} - + ); diff --git a/src/shared-components/verificationMessages/__snapshots__/test.tsx.snap b/src/shared-components/verificationMessages/__snapshots__/test.tsx.snap index d772a285f..ecc625d85 100644 --- a/src/shared-components/verificationMessages/__snapshots__/test.tsx.snap +++ b/src/shared-components/verificationMessages/__snapshots__/test.tsx.snap @@ -26,44 +26,60 @@ exports[` UI snapshot renders with default props and som style="opacity: 1; max-height: 48px; transition-duration: 350ms; transition-property: max-height, opacity; transition-timing-function: ease-in-out;" type="error" > - - Uh oh! - - This field is required + + + Uh oh! + + This field is required +
  • - - Uh oh! - - Must be at least 3 characters + + + Uh oh! + + Must be at least 3 characters +
  • - Must contain 1 number - , - Must contain 1 symbol + + Must contain 1 number + , + Must contain 1 symbol +
  • - - 1 - - one - , - - 2 - - two + + + 1 + + one + , + + 2 + + two +
  • `; @@ -95,10 +111,14 @@ exports[` UI snapshot renders with non-default props 1`] style="opacity: 1; max-height: 48px; transition-duration: 350ms; transition-property: max-height, opacity; transition-timing-function: ease-in-out;" type="success" > - - Congrats! - - Your app was approved + + + Congrats! + + Your app was approved + `; diff --git a/src/shared-components/verificationMessages/index.tsx b/src/shared-components/verificationMessages/index.tsx index bf4d80c28..3f71ce70e 100644 --- a/src/shared-components/verificationMessages/index.tsx +++ b/src/shared-components/verificationMessages/index.tsx @@ -14,6 +14,7 @@ export interface VerificationMessagesProps { * Centers the messages */ centered?: boolean; + inputId?: string; /** * Object of key and React Node message pair. It also accepts an array of React Node as value */ @@ -32,6 +33,7 @@ export interface VerificationMessagesProps { */ export const VerificationMessages: React.FC = ({ centered = false, + inputId, messages = {}, type = 'error', }) => { @@ -54,7 +56,9 @@ export const VerificationMessages: React.FC = ({ .map((key) => ( - {formatMessage(messages[key])} + + {formatMessage(messages[key])} + ))