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

USWDS - Input Mask: (Error Feedback) Code Refactor #6203

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from

Conversation

mlloydbixal
Copy link

@mlloydbixal mlloydbixal commented Nov 13, 2024

Summary

Improve invalid character feedback with error message. Add error messages (customizable via data attributes) to give proper user feedback when an invalid character is not added to the input value.

Breaking change

Indicate if this update is a breaking change with one of the following statements:
This is not a breaking change.
⚠️ This is potentially a breaking change.
⚠️ This is a breaking change.

Related issue

Closes #5481

Related Pull Request

USWDS-Site: Add changelog for input mask [#6203]

Preview link

Preview link

Problem statement

The current state of the input mask component does not provide any audio feedback and very little visual feedback to the user that the character they attempted to add to the input value was rejected. Usability testing showed they were often unaware that the characters were not allowed. The desired state would be feedback to the user via an error message and the appropriate aria-labels that offer context that their input was rejected, what the current state of the input now is, and what the input is expecting from them. This issue affects every user.

Solution

The solution is to provide an error message that is descriptive and dynamic enough so that it updates the user on what the input mask is expecting of them whether it is a letter or a number. Additional aria labeling will provide the same context to screen readers in a message that can be customized separately to give additional instruction if necessary.

Testing and review

  1. Navigate to text input mask component (alphanumeric is best for testing the 3 error message types)
  2. Trigger error message by typing in the wrong input
  3. Confirm the message shown is relevant to the input that the mask is requiring
  4. Repeat this for both numbers and letters to trigger both message types
  5. Test using special characters
  6. When correctly completing the input - no error message should be present. Now continue to type to trigger the message "Maximum character count reached".
  7. When testing using a screen reader the error message should be read to user 1000ms after the error message displays. This message should be able to be customized separately from the one displayed visually.

*There should be no regressions or changes to mask functionality. This is only an error message enhancement.

@mlloydbixal mlloydbixal changed the title Input Mask (Error Feedback) Refactor USWDS - Input Mask: (Error Feedback) Code Refactor Nov 15, 2024
Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

Overall this is looking good! I've only tested the functionality so far. Please don't forget to create unit tests.

Discovered a minor quirk in special characters.

For example
Enter ! the error will flash and disappear, but if you enter = it will stay. Attached GIF below.

capture -Arc-2024-11-19

Comment on lines 16 to 18
{% if dataErrorMessage %}data-errormessage="{{ dataErrorMessage }}"{% endif %}
{% if dataErrorAlphabetical %}data-errormessage-alpha="{{ dataErrorAlphabetical }}"{% endif %}
{% if dataErrorNumerical %}data-errormessage-num="{{ dataErrorNumerical }}"{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

There was some discussion related to the correct name for this in File input PR #6168 1.

The TL;DR is that there's an established naming convention of using something like data-errorMessage. While not a fan of it because it seems unconventional to other USWDS settings, maybe we should use for consistency in error messages.

Footnotes

  1. https://github.com/uswds/uswds/pull/6168#discussion_r1842880357

Copy link
Author

@mlloydbixal mlloydbixal Dec 6, 2024

Choose a reason for hiding this comment

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

Fixed in c4bfd9b (I think I got it right but the thread was a little confusing to follow, let me know if I should make any adjustments)

@mlloydbixal
Copy link
Author

@mejiaj thanks for the draft feedback! Good catch on that bug :O

@mlloydbixal
Copy link
Author

Overall this is looking good! I've only tested the functionality so far. Please don't forget to create unit tests.

Discovered a minor quirk in special characters.

For example Enter ! the error will flash and disappear, but if you enter = it will stay. Attached GIF below.

capture -Arc-2024-11-19

I think it has something to do with holding down the shift button. I will add this edge case - good catch!

@mlloydbixal
Copy link
Author

mlloydbixal commented Nov 21, 2024

I'm working on refining the error message so that a screen reader user understands their invalid character was not added to the input. There was some confusion from users if they needed to backspace or not (and they don't need to). I'm wondering if updating the message to say "Error: please enter a number. Your last entry was not added to the value." is descriptive enough OR if we need to adjust functionality to read them back their whole input like "Error: please enter a number. Currently the input value is "a1b 2c"

I notice in VO it reads the new full input value after a character has been accepted, but not when it's rejected.

Thoughts?
@amyleadem @amycole501

@amycole501
Copy link

I prefer your second wording. And in JAWS typically nothing is read aloud for me unless I backspace to hear it. Most JAWS and NVDA users I suspect will be used to arrowing backwards to hear each character. That said, hearing the entire data field announced sounds like a great enhancement!

@mlloydbixal mlloydbixal marked this pull request as ready for review December 2, 2024 20:59
@mlloydbixal mlloydbixal requested a review from a team as a code owner December 2, 2024 20:59
@mejiaj
Copy link
Contributor

mejiaj commented Dec 3, 2024

@mlloydbixal can you please look into the build errors?

@cathybaptista
Copy link
Contributor

Hi, @mlloydbixal!

I realize you didn't officially request that I review this, but I checked it out anyway. I noticed the issues that James already pointed out, plus when I entered "A" in the alphanumeric field, it showed me an error, probably for the same reason as you mentioned, the shift key. Whatever this is it is also causing this... if you enter a lowercase letter in the same variant that's fine, but then if you enter a $ or some other special character, I am getting the error message Maximum character count reached, and I don't think that's right? If I enter a lowercase letter and then another lc letter I get please enter a number. If you hold down the shift key I can see the right message in Firefox or Arc.

I also am not a UI guru (and certainly not for USWDS), but is the error message too close to the input? Also, how do we feel about the language "Error:" we use "Maximum character count reached" so is that OK for the others? Like Please enter a number and not Error: please enter a number? Just my two cents. ;)

@mlloydbixal
Copy link
Author

mlloydbixal commented Dec 5, 2024

@cathybaptista thanks for giving it a test! That was a regression caused earlier this week after satisfying lint errors..ugh. I fixed it this morning if you want to take a second look.

Also - regarding your last comment - adding "Error:" to those messages was a request from @amycole501 per an earlier discussion. I didn't think it's necessary to also add it to "Maximum character count reached" because it's not really an error or something that needs to be corrected. That message is just letting the user know they can't add anymore characters. @jaclinec @alex-hull any thoughts on that wording? The preview link in the PR is up to date with all bugs solved if you'd like to see the message types.

@mlloydbixal
Copy link
Author

@mejiaj @amyleadem @mahoneycm ready for re-review 🥳

@mlloydbixal
Copy link
Author

Overall this is looking good! I've only tested the functionality so far. Please don't forget to create unit tests.

Discovered a minor quirk in special characters.

For example Enter ! the error will flash and disappear, but if you enter = it will stay. Attached GIF below.

capture -Arc-2024-11-19

Bug was resolved in 81f10da and again in 616c6e3 after a regression

@jaclinec
Copy link

jaclinec commented Dec 6, 2024

@cathybaptista thanks for giving it a test! That was a regression caused earlier this week after satisfying lint errors..ugh. I fixed it this morning if you want to take a second look.

Also - regarding your last comment - adding "Error:" to those messages was a request from @amycole501 per an earlier discussion. I didn't think it's necessary to also add it to "Maximum character count reached" because it's not really an error or something that needs to be corrected. That message is just letting the user know they can't add anymore characters. @jaclinec @alex-hull any thoughts on that wording? The preview link in the PR is up to date with all bugs solved if you'd like to see the message types.

I agree that we probably don't need to use "error" for maximum character count reached since, as you said, it's more informational rather than something they need to fix. But it does make sense to use "error" in the message when they type an invalid character (like a letter instead of a number) since they'll need to fix the error.

@cathybaptista
Copy link
Contributor

@mlloydbixal and @jaclinec Sounds good to me! This is looking awesome! :)

While I was confirming, I did find one thing you might just want to check... if I go to Alphnumeric, enter a letter (no problems) and then enter a special character (I tried this with the space bar and the control key), I get an Error: Please Enter a Letter message. If I follow that message, I get "Error: please enter a number", which is right. Here is a vid... showing the space and then the letter:

Screen.Recording.2024-12-06.at.3.24.29.PM.mov

:)
Cathy

@mlloydbixal
Copy link
Author

@cathybaptista can you test again using the "open canvas in new tab" button? I think because of the way we have a double compile in the build sometimes updates lag behind when you are testing inside the storybook window. If I test inside the storybook window I see even worse results than what you shared. Try going to this preview link or locally. Sorry for the confusion :)

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.

USWDS - Input Mask refactor: Recovering from an error is difficult due to lack of feedback.
5 participants