From 87f0806a4f63211042c75ce289aeeb3109dae78e Mon Sep 17 00:00:00 2001 From: juhomakkonen <69158965+juhomakkonen@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:43:38 +0300 Subject: [PATCH] Feature/improve accessibility (#14) * Add ids to inputs, labels & texts * Add id values into form elements --- src/components/Forms/EmailForm/EmailForm.tsx | 1 + src/components/Forms/UserForm/UserForm.tsx | 12 ++++++++++-- .../Tables/TableCommon/TableCommon.tsx | 14 +++++++------- .../Tables/TableExtended/TableExtended.tsx | 16 ++++++++++------ .../__tests__/TableExtended.test.tsx | 5 +++-- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/components/Forms/EmailForm/EmailForm.tsx b/src/components/Forms/EmailForm/EmailForm.tsx index 4ac6af10..5bd3482b 100644 --- a/src/components/Forms/EmailForm/EmailForm.tsx +++ b/src/components/Forms/EmailForm/EmailForm.tsx @@ -57,6 +57,7 @@ const EmailForm = () => { {
-
{
handlePostalCodeStates(event, setIsPostalCodeOther)} @@ -303,6 +307,7 @@ const UserForm = ({ answerStatus, setAnswerStatus }: UserFormProps) => { required: false, })} role="listbox" + id="optional_postal_code" onChange={(event) => handlePostalCodeStates(event, setIsOptionalPostalCode)} disabled={isOptionalPostalCodeOther} aria-required="false" @@ -331,6 +336,7 @@ const UserForm = ({ answerStatus, setAnswerStatus }: UserFormProps) => {
@@ -362,11 +368,12 @@ const UserForm = ({ answerStatus, setAnswerStatus }: UserFormProps) => { -
@@ -374,6 +381,7 @@ const UserForm = ({ answerStatus, setAnswerStatus }: UserFormProps) => { = ({ question }) => { mainOption.option === option.id)} onChange={(event) => createAnswerEvent(event, option)} - aria-disabled={ - limitSelections && - mainOptions.length >= 3 && - disabledOptions.includes(option.id) - } disabled={ limitSelections && mainOptions.length >= 3 && @@ -161,12 +157,14 @@ const TableCommon: React.FC = ({ question }) => { {option.is_other ? ( setOtherValue(event.target.value)} + aria-describedby={`charCount_${option.id}`} placeholder={renderLocaleValue( getLocaleText, option.value_fi, @@ -174,13 +172,15 @@ const TableCommon: React.FC = ({ question }) => { option.value_sv, )} /> - {`${otherCount}/${maxCount} ${intl.formatMessage({ + {`${otherCount}/${maxCount} ${intl.formatMessage({ id: 'app.form.helperText.characters', })}`} ) : ( -