-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - Input mask: Version 2 #5227
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
Open
amyleadem
wants to merge
85
commits into
develop
Choose a base branch
from
al-input-mask
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…/uswds/uswds into jb-inclusive-patterns-input-mask
…aced with typed characters
…ter and more refactoring
… allowing letters in a numeric only mask
… the table component
Input mask: validate on paste cleanup
This was referenced May 23, 2023
2 tasks
This was referenced Aug 31, 2023
This was referenced Sep 27, 2023
2 tasks
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Updated input mask functionality and attributes. This update simplifies the mask attribute requirements, provides instant feedback to the user if they enter an invalid character, and allows for better keyboard controls.
Some notes:
mm-input-mask
) in PR USWDS input mask version 2 #5104 appears to have been corrupted and/or is missing commits. This PR attempts to fill in the gaps in history and resolve items that were identified in the comments of that PR.Breaking change
usa-input-mask
class. Before the class was namedusa-masked
.mask
attribute requires different values thanpattern
anddata-charset
did before. See "Component attribute updates" table below for details.Related issues
Closes #5054, closes #5227.
Documentation update issue: uswds/uswds-site#2062
Related pull requests
This work originates from PR #5104
Documentation update (WIP): uswds/uswds-site#2073
Preview link
Preview link: Input mask
Major changes
This is a significant rewrite that:
Improved end-user interaction
(
in phone numbers)Enhanced input mask creation attributes
pattern
anddata-charset
attributes with themask
attribute, which accepts the letterA
to represent any alphabetic character, the number9
to represent any numeric character, and format characters like-
and/
index.js
.data-invalid-alpha-text
anddata-invalid-numeric-text
attributesforceupper
andforcelower
attributesImproved developer experience
Component attribute updates
Please enter a letter character here
Please enter a number character here
forcelower="true"
to the input element to enforce lowercase letters.forceupper="true"
to the input element to enforce uppercase letters.inputmode
to numeric to display a numeric keyboard. Setinputmode
totel
to display a telephone keyboard. Setinputmode
totext
if your input mask includes alphabetic characters.9
to represent any number, the letterA
to represent any letter, and any format character needed in your mask. For example, an input that requires three numbers followed by four letters with a hyphen in-between would have amask
attribute that looks like999-AAAA
._
for character input placeholders combined with any valid format characters to customize your input mask. For example, a U.S. telephoneplaceholder
attribute may look like(___) ___-____
.Problem statement
Comment from PR #5104:
Solution
Tasks completed since #5104
forceupper
andforcelower
attribute controls to storybook (53a0b8a)usa-input-mask__field
markup requirementusa-input-mask
from container element to the input itself. This replaced the need for.usa-input-mask__field
. (9a49a4e)aria-describedby
with SR status message elementusa-form
andusa-form-group
with other form componentsusa-input-mask
from a container element to the input element itself. This means thatusa-form
andusa-form-group
are no longer contained insideusa-input-mask
. (9a49a4e)usa-error-message
class (a16a662)mask
,placeholder
(ede9b6f)aria-describedby
connection done in 8f4f646FORMAT_CHARACTERS
@
into the first position triggers a "Please enter a valid number character here", but the pattern is expecting a letter.A
into the first position, then try copying the stringBC1234
orBC-1234
to finish it out.Cut
/ctrl
+x
orctrl
+backspace
removes chunk of placeholderAdd clarity to hint examplesOpen discussion items
From @thisisdano in #5227 (comment)):
Other questions :
Outstanding items
Proposing we open new issues for these
.
in MacOS and causes a break in the inputmaxlength
has been reached(
in voiceoverTesting and review
Confirm that the component meets functionality requirements as defined in the Input Mask requirements document (Google docs) 🔒