File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
src/components/absences/modals Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 44 FormLabel ,
55 Text ,
66} from '@chakra-ui/react' ;
7+ import { useId } from 'react' ;
78import { SearchDropdown } from './SearchDropdown' ;
89
910interface AdminTeacherFieldsProps {
@@ -28,14 +29,21 @@ export const AdminTeacherFields: React.FC<AdminTeacherFieldsProps> = ({
2829 setFormData,
2930 setErrors,
3031} ) => {
32+ const id = useId ( ) ;
33+
3134 return (
3235 < >
3336 < FormControl isRequired isInvalid = { ! ! errors . absentTeacherId } >
34- < FormLabel htmlFor = "absentTeacher" sx = { { display : 'flex' } } >
37+ < FormLabel
38+ id = { 'absentTeacherLabel' + id }
39+ as = "p"
40+ sx = { { display : 'flex' } }
41+ >
3542 < Text textStyle = "h4" > Teacher Absent</ Text >
3643 </ FormLabel >
3744 < SearchDropdown
3845 id = "absentTeacher"
46+ ariaLabelledBy = { 'absentTeacherLabel' + id }
3947 excludedId = { formData . substituteTeacherId }
4048 defaultValueId = { Number ( formData . absentTeacherId ) }
4149 onChange = { ( value ) => {
@@ -55,11 +63,16 @@ export const AdminTeacherFields: React.FC<AdminTeacherFieldsProps> = ({
5563 </ FormControl >
5664
5765 < FormControl >
58- < FormLabel htmlFor = "substituteTeacher" sx = { { display : 'flex' } } >
66+ < FormLabel
67+ id = { 'substituteTeacherLabel' + id }
68+ as = "p"
69+ sx = { { display : 'flex' } }
70+ >
5971 < Text textStyle = "h4" > Substitute Teacher</ Text >
6072 </ FormLabel >
6173 < SearchDropdown
6274 id = "substituteTeacher"
75+ ariaLabelledBy = { 'substituteTeacherLabel' + id }
6376 excludedId = { formData . absentTeacherId }
6477 defaultValueId = {
6578 formData . substituteTeacherId
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ export type Option = { name: string; id: number; profilePicture: string };
2121
2222interface SearchDropdownProps {
2323 id : string ;
24+ ariaLabelledBy : string ;
2425 excludedId ?: string ;
2526 defaultValueId ?: number ;
2627 onChange : ( value : Option | null ) => void ;
2728}
2829
2930export const SearchDropdown : React . FC < SearchDropdownProps > = ( {
3031 id,
32+ ariaLabelledBy,
3133 excludedId,
3234 defaultValueId,
3335 onChange,
@@ -174,6 +176,7 @@ export const SearchDropdown: React.FC<SearchDropdownProps> = ({
174176 id = { id }
175177 name = { id }
176178 ref = { inputRef }
179+ aria-labelledby = { ariaLabelledBy }
177180 value = { searchQuery }
178181 onChange = { isSelected ? undefined : handleSearchChange }
179182 onClick = { ( ) => {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { Absence, Prisma } from '@prisma/client';
1414import { formatFullDate } from '@utils/dates' ;
1515import { submitAbsence } from '@utils/submitAbsence' ;
1616import { validateAbsenceForm } from '@utils/validateAbsenceForm' ;
17- import { useState , useId } from 'react' ;
17+ import { useId , useState } from 'react' ;
1818import { useCustomToast } from '../../../CustomToast' ;
1919import { FileUpload } from '../../FileUpload' ;
2020import { AdminTeacherFields } from '../AdminTeacherFields' ;
@@ -340,7 +340,7 @@ const DeclareAbsenceForm: React.FC<DeclareAbsenceFormProps> = ({
340340
341341 < FormControl isRequired isInvalid = { ! ! errors . subjectId } >
342342 < FormLabel id = { 'subjectLabel' + id } as = "p" sx = { { display : 'flex' } } >
343- < Text textStyle = "h4" > Subject</ Text >
343+ < Text textStyle = "h4" > Subject</ Text >
344344 </ FormLabel >
345345 < InputDropdown
346346 ariaLabelledBy = { 'subjectLabel' + id }
You can’t perform that action at this time.
0 commit comments