Skip to content

fix: add id/name attributes and labels to form fields for accessibili…#399

Open
ARUSHIGULBHILE wants to merge 1 commit into
GitMetricsLab:mainfrom
ARUSHIGULBHILE:fix/issue-388
Open

fix: add id/name attributes and labels to form fields for accessibili…#399
ARUSHIGULBHILE wants to merge 1 commit into
GitMetricsLab:mainfrom
ARUSHIGULBHILE:fix/issue-388

Conversation

@ARUSHIGULBHILE
Copy link
Copy Markdown

@ARUSHIGULBHILE ARUSHIGULBHILE commented May 22, 2026

Related Issue

Closes #388


Description

Added missing id, name, and label attributes to form fields across the application to resolve accessibility warnings.

Files changed:

  • src/components/Footer.tsx - newsletter email input
  • src/pages/Contact/Contact.tsx - name, email, subject, message fields
  • src/pages/Login/Login.tsx - email, password fields
  • src/pages/Signup/Signup.tsx - username, email, password fields
  • src/pages/Tracker/Tracker.tsx - MUI Select component (State filter)

Changes made:

  • Added id and name attributes to all form inputs
  • Added associated <label> tags with htmlFor matching the id
  • Added autoComplete="off" to MUI Select component
  • Used sr-only class for screen-reader accessible labels

How Has This Been Tested?

  1. Ran npm run dev locally
  2. Opened browser console (F12)
  3. Verified that the warning "A form field element should have an id or name attribute" no longer appears
  4. Tested all forms (Login, Signup, Contact) to ensure they still work correctly

Screenshot (After Fix)

The original warning "A form field element should have an id or name attribute" is gone. Only unrelated autocomplete and label warnings remain (separate issues).
Screenshot 2026-05-22 140350


Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

Release Notes

  • Accessibility Improvements
    • Enhanced form accessibility across the application by adding screen-reader-friendly labels and proper form field associations to newsletter subscription, contact, login, signup, and tracker filter forms.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 0ff867b
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a10183a463ad200079711d7
😎 Deploy Preview https://deploy-preview-399--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

This pull request addresses accessibility violations across form fields in the application by adding missing id, name attributes, and properly associated <label> elements. The changes affect the contact form, login form, signup form, tracker filter select, and footer newsletter subscription field.

Changes

Form Field Accessibility Enhancements

Layer / File(s) Summary
Contact form field accessibility
src/pages/Contact/Contact.tsx
Full Name, Email Address, Subject, and Message form controls now include matching id/name attributes and labels with htmlFor references linking each label to its corresponding input.
Login form field accessibility
src/pages/Login/Login.tsx
Email and password fields include sr-only labels linked via matching id and htmlFor attributes for screen reader support.
Signup form field accessibility and button ARIA attributes
src/pages/Signup/Signup.tsx
Username, email, and password inputs are updated with sr-only labels and explicit id attributes; the password visibility toggle button includes aria-label and aria-pressed attributes tied to the visibility state.
Tracker state filter select accessibility
src/pages/Tracker/Tracker.tsx
The state filter select element is assigned id, name, and autoComplete="off" attributes for proper form field identification and accessibility.
Footer newsletter email input accessibility
src/components/Footer.tsx
The newsletter email input is wrapped in a div container with an sr-only label element, and the input now includes id and name attributes to establish the label-input association.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

type:accessibility, level:intermediate, quality:clean

Poem

🐰 A hop, skip, and a label leap!
With id and name so form fields reap,
Screen readers chirp, and bunny's so deep,
Accessibility standards to keep! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding id/name attributes and labels to form fields for accessibility improvements.
Description check ✅ Passed The description comprehensively follows the template with all required sections filled: related issue, detailed description, testing methodology, screenshots, and type of change.
Linked Issues check ✅ Passed All coding requirements from issue #388 are met: id/name attributes added to form fields, labels with htmlFor added, and accessibility warnings resolved as demonstrated.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #388 objectives; no extraneous modifications to unrelated functionality were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/pages/Tracker/Tracker.tsx (1)

300-326: ⚡ Quick win

Consider adding explicit label association for MUI Select.

For more explicit accessibility, consider adding an id to the InputLabel and a labelId to the Select:

♻️ Optional improvement for explicit label association
-        <FormControl sx={{ minWidth: 150 }}>
-          <InputLabel sx={{ fontSize: "14px" }}>State</InputLabel>
+        <FormControl sx={{ minWidth: 150 }}>
+          <InputLabel id="state-select-label" sx={{ fontSize: "14px" }}>State</InputLabel>
           <Select
             id="state-select"
+            labelId="state-select-label"
             name="state-select"
             autoComplete="off"

This makes the label-to-input association more explicit and aligns with Material-UI best practices, though the current implementation with the label="State" prop should work correctly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/Tracker/Tracker.tsx` around lines 300 - 326, Add explicit label
association for the MUI Select by giving the InputLabel an id (e.g.,
"state-select-label") and passing that id into the Select's labelId prop; update
the InputLabel component (InputLabel) to include the id and update the Select
component (Select with id "state-select") to include
labelId="state-select-label" so the label and select are explicitly linked for
accessibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/pages/Tracker/Tracker.tsx`:
- Around line 300-326: Add explicit label association for the MUI Select by
giving the InputLabel an id (e.g., "state-select-label") and passing that id
into the Select's labelId prop; update the InputLabel component (InputLabel) to
include the id and update the Select component (Select with id "state-select")
to include labelId="state-select-label" so the label and select are explicitly
linked for accessibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2dba50d1-a867-47f5-a560-1803466fad46

📥 Commits

Reviewing files that changed from the base of the PR and between 9d34c19 and 0ff867b.

📒 Files selected for processing (5)
  • src/components/Footer.tsx
  • src/pages/Contact/Contact.tsx
  • src/pages/Login/Login.tsx
  • src/pages/Signup/Signup.tsx
  • src/pages/Tracker/Tracker.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Form fields missing id/name attributes causing accessibility warnings

1 participant