Skip to content

Update ARIA labels / described by on IDV doc auth FileInput component#7287

Merged
matthinz merged 3 commits intomainfrom
matthinz/lg-7770-file-input-label
Nov 4, 2022
Merged

Update ARIA labels / described by on IDV doc auth FileInput component#7287
matthinz merged 3 commits intomainfrom
matthinz/lg-7770-file-input-label

Conversation

@matthinz
Copy link
Contributor

@matthinz matthinz commented Nov 3, 2022

🎫 Ticket

LG-7770

🛠 Summary of changes

Testing identified that users wanted more detail in the ARIA label attached to the FileInput component in the IDV doc auth upload step. The request here was that the label include not only the field name ("Front of ID" / "Back of ID"), but the next step as well ("drag file here or choose from folder").

How it used to be

Previously, there were two separate hints attached via the aria-describedby attribute: "Drag file here..." and "Must be a JPG or PNG".

Some screen readers (tested in JAWS) would not read this aria-describedby content initially without the user triggering it in some way, leading to a confusing experience where the user would focus the control and just hear "Front of ID, button".

What I changed

This change reworks the component to use aria-labelledby to refer to the field name and next step elements, while leaving the "Must be a JPG or PNG" in aria-describedby.

The result is the user hearing e.g. "Front of ID - drag file here or choose from folder" on focus, followed by "Must be a JPG or PNG" .

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

  • Visit the document upload page of the IDV workflow
  • Turn on your screen reader
  • Tab between the "Front of ID" and "Back of ID" fields and listen to the screen reader

👀 Screenshots

Videos of the new functionality are in this Slack thread.

🚀 Notes for Deployment

N/A

When FileInput does not have a file added to it, ensure ARIA label includes the prompt to drag + drop a file.

User testing found this was needed, as JAWS does not automatically read `aria-describedby` by default (it requires extra interaction).

changelog: Improvements, Accessibility, Improve document upload screen reader text
@matthinz matthinz requested a review from a team November 3, 2022 19:14
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

In retrospect, it feels odd to me that a label would include dynamic details of the current state of the input or additional instructions on how to use it (the latter being what I'd expect aria-describedby to be used for), though (a) this is how it has existed already and (b) if the feedback is coming direct from screen reader users themselves, I defer to their judgment as being most familiar with real-world usage. Makes me wonder when (if ever) aria-describedby is the right tool. 🤔

* @param {string} fileLabel String velue of the label for input to display
* @param {string} fileLabel String value of the label for input to display
* @param {Blob|string|null|undefined} fileValue File or string for which to generate label.
* @return {{'aria-label': string} | {'aria-labelledby': string}}
Copy link
Contributor

Choose a reason for hiding this comment

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

This'd be a good file to port to TypeScript, though having just opened the file myself, I see it's a big one, and probably not a task we'd want to undertake here 😅

@matthinz
Copy link
Contributor Author

matthinz commented Nov 4, 2022

I think aria-describedby is probably good and useful. This issue seemed to be caused by a combination of OS, browser version, screen reader, and having multiple elements referenced in the aria-describedby attribute (which is legal per spec but I can't help but feel might be one of those gray areas that doesn't get tested much).

Agree, about the TS conversion, I'll file a cleanup ticket.

@matthinz matthinz merged commit 7df4ca0 into main Nov 4, 2022
@matthinz matthinz deleted the matthinz/lg-7770-file-input-label branch November 4, 2022 21:52
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