From 47092c96fc67826e1f8913fdccac2418bb17e332 Mon Sep 17 00:00:00 2001 From: dakahn Date: Fri, 15 Oct 2021 10:47:31 -0500 Subject: [PATCH] fix(TextInput): link helper text to input in default state --- packages/react/src/components/TextInput/TextInput.js | 6 +++++- packages/react/src/internal/useNormalizedInputProps.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/TextInput/TextInput.js b/packages/react/src/components/TextInput/TextInput.js index 8ce8d7b0f3e9..6622c4b684ca 100644 --- a/packages/react/src/components/TextInput/TextInput.js +++ b/packages/react/src/components/TextInput/TextInput.js @@ -85,6 +85,7 @@ const TextInput = React.forwardRef(function TextInput( title: placeholder, disabled: normalizedProps.disabled, readOnly, + ['aria-describedby']: normalizedProps.helperId, ...other, }; const inputWrapperClasses = classNames( @@ -134,8 +135,11 @@ const TextInput = React.forwardRef(function TextInput( {labelText} ) : null; + const helper = helperText ? ( -
{helperText}
+
+ {helperText} +
) : null; const input = ( diff --git a/packages/react/src/internal/useNormalizedInputProps.js b/packages/react/src/internal/useNormalizedInputProps.js index f0fa7b6ba83e..de4ba8fa2e5b 100644 --- a/packages/react/src/internal/useNormalizedInputProps.js +++ b/packages/react/src/internal/useNormalizedInputProps.js @@ -67,6 +67,7 @@ export function useNormalizedInputProps({ warnId: `${id}-warn-msg`, validation: null, icon: null, + helperId: `${id}-helper-text`, }; if (readOnly) {