Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a11y): Add labels to all feedback form inputs #2939

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Mar 28, 2024

What does this PR do?

  • Address accessibility report issue "Label and Accessible Name" (page 43)
  • Adds a label to each input used in the feedback from instead of conditionally relying on the title for this

This approach is very much up for discussion, I've hopefully explained my thought process below.

Problem

A text area was found to have an accessible name that does not match the one that is provided visually. This can be found across the service; however, this instance relates to the text area below the ‘please help us to improve the service by sharing feedback’. The visual label has not been programmatically associated with the related text area, and so the information presented visually is not relayed to screen reader users navigating out of context.

<textarea 
  aria-describedby="comment-title" 
  name="userComment" 
  required="" 
  // Hardcoded aria-label is the issue
  aria-label="Leave your feedback"
  class="MuiInputBase-input MuiInputBase-inputMultiline css-10oer18" 
  style="height: 29px; overflow: hidden;">
 </textarea>

Why I went for this approach

There are a few ways this issue could be addressed. The report suggests wrapping making the title (e.g. "Please help us to improve this service by sharing feedback" a <label> element and attaching to the input using id and for properties.

I've opted not to do this, and instead to always add a label for each input, separate from the title.

Pros

  • It's consistent across all modes the feedback component can take. Currently labels are used where multiple inputs are used, but not single inputs (apart from "Report an inaccuracy").
  • Relying on an external title to label our form component is quite unexpected
    • The FeedbackForm component cannot pass automated accessibility tests unless accompanied by another label component
    • We rely on all future users of this component to know and understand this
  • Passing a title component into the form ends up being fairly complex / invovled
    • It needs to have different styles in different contexts (e.g. icon or no icon, font size)
    • It needs the component={label} prop (or aria-labelledby) if there is only a single input
  • I think the title and label are actually two different things in reality

Cons

  • More text / cruft for the user
  • Bad copy written by me!

Thoughts most welcome! 😄

@DafyddLlyr DafyddLlyr changed the title fix: Add labels to all feeback form inputs fix(a11y): Add labels to all feedback form inputs Mar 28, 2024
@DafyddLlyr DafyddLlyr marked this pull request as ready for review March 28, 2024 11:59
Copy link

github-actions bot commented Mar 28, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr
Copy link
Contributor Author

Copy link
Contributor

@Mike-Heneghan Mike-Heneghan left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for resolving the issue and for the clear reasoning behind it!

There's a small non-blocking comment around removing stories about the unlabelled input which doesn't exist any more.

@DafyddLlyr DafyddLlyr merged commit 4558c2c into main Apr 2, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/feedback-labels-a11y branch April 2, 2024 14:38
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