Visitar URL original
USWDS - Password: Replace link with button by amyleadem · Pull Request #4847 · uswds/uswds · GitHub
Skip to content

USWDS - Password: Replace link with button - #4847

Merged
thisisdano merged 9 commits into
developfrom
al-password-button
Jul 28, 2022
Merged

thisisdano merged 9 commits into
developfrom
al-password-button

Conversation

@amyleadem

@amyleadem amyleadem commented Jul 6, 2022 •

Copy link
Copy Markdown
Contributor

Summary

⚠️ Updated markup in the usa-password package 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:

  1. Open the updated sign-in template page
  2. Confirm that the button element has the appropriate markup
  3. Confirm that the button appearance matches current style
  4. Confirm that the show/hide functionality works as expected by typing anything in the password field and then click on the Show password and Hide password button.
  5. Confirm that prior markup still looks and behaves as expected by injecting the following via web inspector.
<p class="usa-form__note">
  <a title="Toggle password" href="" class="usa-show-password" aria-controls="password-sign-in" data-show-text="Show password" data-hide-text="Hide password">Show password</a>
</p>

Before you hit Submit, make sure you’ve done whichever of these applies to you:

@amyleadem
amyleadem marked this pull request as ready for review July 11, 2022 21:41
@amyleadem
amyleadem requested a review from mejiaj July 11, 2022 21:42

.usa-form__note {
.usa-form__note,
.usa-form__note.usa-button--unstyled {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This component has 2 selectors that aren't used anywhere else.

  1. .usa-form__note
  2. .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);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clean. Thanks!
I also included usa-show-multipassword, though I am not really sure where/how we use that.

Updated in 1293e5f

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@amyleadem
amyleadem requested a review from mejiaj July 27, 2022 22:28
@amyleadem
amyleadem requested a review from thisisdano July 27, 2022 22:39
@amyleadem

Copy link
Copy Markdown
Contributor Author

@thisisdano @mejiaj I removed the references to usa-show-multipassword in bd78578. Please let me know if you need anything else.

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.

Password masking show/hide should be button not link

3 participants