Repository navigation
USWDS - Password: Replace link with button - #4847
Conversation
|
|
||
| .usa-form__note { | ||
| .usa-form__note, | ||
| .usa-form__note.usa-button--unstyled { |
There was a problem hiding this comment.
This component has 2 selectors that aren't used anywhere else.
.usa-form__note.usa-show-password
Instead of adding additional classes in the markup, we could use a mixin. If we have markup like this:
<button
title="toggle password"
type="button"
class="usa-form__note usa-show-password"
aria-controls="password-reset confirmPassword"
data-show-text="Show my typing"
data-hide-text="Hide my typing">
Show my typing
</button>We can use a less specific selector in our SASS.
.usa-show-password {
@include button-unstyled;
}
.usa-form__note,
.usa-show-password {
@include typeset($theme-form-font-family, "2xs", 3);
float: right;
margin: units(0.5) 0 units(2);
}
There was a problem hiding this comment.
Clean. Thanks!
I also included usa-show-multipassword, though I am not really sure where/how we use that.
Updated in 1293e5f
There was a problem hiding this comment.
Great thanks! Where is usa-show-multipassword used? If it's a variant for show-password we could do BEM-style usa-show-password--multi.
There was a problem hiding this comment.
I see it only in these files:
https://github.com/uswds/uswds/blob/develop/packages/uswds-core/src/js/utils/test/toggle-form-input.spec.js#L8
https://github.com/uswds/uswds/blob/develop/packages/uswds-core/src/js/utils/test/toggle.template.html#L5
https://github.com/uswds/uswds/blob/develop/packages/_usa-password/src/index.js#L7
It seems to be the same as usa-show-password? Am I missing something?
There was a problem hiding this comment.
@mejiaj I am not seeing that usa-show-multipassword is actively in use in our demos or documentation. Looking back through the history, I see that usa-show-multipassword is used in the password reset form in 2.13.3, but switches to usa-show-password in 3.0.0-beta.1. From that point on usa-show-multipassword is only found in tests.
Do you know anything about the switch? Is multipassword intended to be deprecated? Either way, they appear to be equivalent. Can we leave it as is for now?
There was a problem hiding this comment.
I think the only difference is in the number of fields. There's a template that has 2 fields, 1 for setting and another for confirming that can be toggled by a single button.
|
@thisisdano @mejiaj I removed the references to |
Summary
usa-passwordpackage to use a<button>element instead of an anchor element. This markup is more semantically appropriate for the related on-page user interaction.Related issue
Closes #4592
Preview link
Preview link: Sign-in pattern template
Problem statement
Interactive on-page actions should be controlled by
<button>elements instead of<a>elements. However, our show/hide password functionality in our sign-in template us declared with an<a>tag, despite being related to an on-page action.Solution
Replace the
<a>element with a<button>in the sign-in template.Note: This is not a breaking change. Using the old markup will still render a result that looks and behaves as expected.
Testing and review
To review:
Show passwordandHide passwordbutton.Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm testand make sure the tests for the files you have changed have passed.