Skip to content

Commit 1c13c64

Browse files
juliajforestiCopilot
andcommitted
fix: improve a11y in CreateDiscussion and DefaultParentRoomField components
Co-authored-by: Copilot <copilot@github.com>
1 parent 44bc00c commit 1c13c64

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
1515
import { GenericModal } from '@rocket.chat/ui-client';
1616
import { useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
1717
import { useMutation } from '@tanstack/react-query';
18-
import { useState } from 'react';
18+
import { useId, useState } from 'react';
1919
import { useForm, Controller } from 'react-hook-form';
2020

2121
import { useEncryptedRoomDescription } from '../../navbar/NavBarPagesGroup/actions/useEncryptedRoomDescription';
@@ -49,6 +49,7 @@ const CreateDiscussion = ({
4949
encryptedParentRoom = false,
5050
}: CreateDiscussionProps) => {
5151
const t = useTranslation();
52+
const parentRoomId = useId();
5253

5354
const [encryptedDisabled, setEncryptedDisabled] = useState(encryptedParentRoom);
5455

@@ -124,7 +125,7 @@ const CreateDiscussion = ({
124125
<Controller
125126
control={control}
126127
name='parentRoom'
127-
render={() => <DefaultParentRoomField defaultParentRoom={defaultParentRoom} aria-required='true' />}
128+
render={({ field }) => <DefaultParentRoomField {...field} defaultParentRoom={defaultParentRoom} required={true} />}
128129
/>
129130
)}
130131
{!defaultParentRoom && (
@@ -134,6 +135,7 @@ const CreateDiscussion = ({
134135
rules={{ required: t('Required_field', { field: t('Discussion_target_channel') }) }}
135136
render={({ field: { name, onBlur, onChange, value } }) => (
136137
<RoomAutoComplete
138+
aria-label={t('Discussion_target_channel')}
137139
name={name}
138140
onBlur={onBlur}
139141
onChange={onChange}
@@ -142,14 +144,16 @@ const CreateDiscussion = ({
142144
placeholder={t('Search_options')}
143145
disabled={Boolean(defaultParentRoom)}
144146
aria-required='true'
147+
aria-invalid={Boolean(errors.parentRoom?.message)}
148+
aria-describedby={errors.parentRoom ? `${parentRoomId}-error` : undefined}
145149
setSelectedRoom={onParentRoomChange}
146150
renderRoomIcon={({ encrypted }) => (encrypted ? <Icon name='key' /> : null)}
147151
/>
148152
)}
149153
/>
150154
)}
151155
</FieldRow>
152-
{errors.parentRoom && <FieldError>{errors.parentRoom.message}</FieldError>}
156+
{errors.parentRoom && <FieldError id={`${parentRoomId}-error`}>{errors.parentRoom.message}</FieldError>}
153157
</Field>
154158
<Field>
155159
<FieldLabel required>{t('Name')}</FieldLabel>

apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Skeleton, TextInput, Callout } from '@rocket.chat/fuselage';
1+
import { Skeleton, Callout } from '@rocket.chat/fuselage';
2+
import { TextInput } from '@rocket.chat/fuselage-forms';
23
import { useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
34
import { useQuery } from '@tanstack/react-query';
45
import type { ComponentPropsWithoutRef } from 'react';

apps/meteor/client/navbar/NavBarPagesGroup/actions/CreateTeamModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ const CreateTeamModal = ({ onClose }: CreateTeamModalProps) => {
177177
validate: (value) => validateTeamName(value),
178178
}}
179179
render={({ field }) => (
180-
<TextInput {...field} addon={<Icon size='x20' name={isPrivate ? 'team-lock' : 'team'} />} error={errors.name?.message} />
180+
<TextInput
181+
{...field}
182+
addon={<Icon size='x20' name={isPrivate ? 'team-lock' : 'team'} />}
183+
error={errors.name?.message}
184+
aria-required='true'
185+
/>
181186
)}
182187
/>
183188
</FieldRow>

0 commit comments

Comments
 (0)