Skip to content

change label to p to prevent label click-through onto input#145

Merged
ChinemeremChigbo merged 3 commits intomainfrom
evelina/fix-label-clickthru
Jan 29, 2026
Merged

change label to p to prevent label click-through onto input#145
ChinemeremChigbo merged 3 commits intomainfrom
evelina/fix-label-clickthru

Conversation

@135ze
Copy link
Collaborator

@135ze 135ze commented Aug 20, 2025

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:

Screenshot 2025-08-19 222206

Checklist

  • PR title is descriptive and in imperative tense
  • Commit messages are descriptive, atomic, and follow best practices
  • Linter(s) have been run
  • Requested reviews from the PL and relevant team members

@135ze 135ze requested a review from ChinemeremChigbo August 20, 2025 23:57
@vercel
Copy link

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sistema Ready Ready Preview, Comment Jan 29, 2026 5:54am

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, updated to match declare form

return (
<FormControl isRequired isInvalid={!!error}>
<FormLabel sx={{ display: 'flex' }}>
<FormLabel as="p" id="dateOfAbsenceLabel" sx={{ display: 'flex' }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to add useId in this and the other forms too

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.
@ChinemeremChigbo ChinemeremChigbo merged commit 871ba0d into main Jan 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants