change label to p to prevent label click-through onto input#145
change label to p to prevent label click-through onto input#145ChinemeremChigbo merged 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
b0a0a4a to
c677038
Compare
There was a problem hiding this comment.
This line and (and also lines 363 and 389) still renders for Room Number, Reason of Absence, and Notes, so clicking those headings continues to focus/activate the fields in the edit modal.
There was a problem hiding this comment.
Right, updated to match declare form
| return ( | ||
| <FormControl isRequired isInvalid={!!error}> | ||
| <FormLabel sx={{ display: 'flex' }}> | ||
| <FormLabel as="p" id="dateOfAbsenceLabel" sx={{ display: 'flex' }}> |
There was a problem hiding this comment.
This hardcodes the id to dateOfAbsenceLabel; when both declare and edit modals mount together this produces duplicate IDs, so the aria-labelledby on the second date field points to the first label and breaks its own accessible name. Consider using React's useId() inside DateOfAbsence or passing an id down via props.
There was a problem hiding this comment.
Updated to add useId in this and the other forms too
aae5e10 to
2a37239
Compare
2a37239 to
d4c171a
Compare
d4c171a to
8bc09ad
Compare
Added unique aria-labelledby attributes and label IDs to the AdminTeacherFields and SearchDropdown components to enhance accessibility. Also fixed minor formatting in DeclareAbsenceForm. These changes ensure better screen reader support for form fields.
Notion Ticket
Clicking the box should open dropdowns/activate the inputs, clicking the text above the dropdowns/input should not
Summary & Review Focus
The "click fowarding" bug occurs because it is built-in to HTML labels, probably for accessibility: https://stackoverflow.com/a/49615087
I am able to change this behaviour by switching the label to be interpreted
as="p". To keep accessibility, I added aria-labelledby, which allows screen readers to still pick up on the purpose of the input without the unwanted behaviour.To verify, run locally and try to click the labels and validate that the dropdowns do not get activated.
Inputs still work because the fields are still populated correctly:
Checklist