-
Notifications
You must be signed in to change notification settings - Fork 938
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% if dataErrorMessage %}data-errormessage="{{ dataErrorMessage }}"{% endif %} | ||
{% if dataErrorAlphabetical %}data-errormessage-alpha="{{ dataErrorAlphabetical }}"{% endif %} | ||
{% if dataErrorNumerical %}data-errormessage-num="{{ dataErrorNumerical }}"{% endif %} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
@mejiaj thanks for the draft feedback! Good catch on that bug :O |
I think it has something to do with holding down the shift button. I will add this edge case - good catch! |
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? |
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 can you please look into the build errors? |
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. ;) |
@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. |
@mejiaj @amyleadem @mahoneycm ready for re-review 🥳 |
Bug was resolved in 81f10da and again in 616c6e3 after a regression |
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. |
@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:) |
@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 :) |
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 potentially a breaking change.
⚠️ This is a breaking change.
This is not 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
*There should be no regressions or changes to mask functionality. This is only an error message enhancement.