Repository navigation
USWDS - Links: Fix invisible text when styled as buttons within forms. Resolves #5066 - #5112
Conversation
|
@mejiaj Added |
amyleadem
left a comment
There was a problem hiding this comment.
This seems like a good, low-impact solution. I confirmed that both standard links and links with .usa-button look as expected inside .usa-form. I checked in Firefox, Safari, Chrome, and Edge.
One thing - can you update the PR description with a summary that can be used in the release notes and changelog?
It also might be good to tag the related issue for 3.4.0.
|
@amyleadem Added a changelog appropriate description! Let me know if you would word this any different:
|
There was a problem hiding this comment.
@mahoneycm The style fix looks good.
Not within the scope of this issue, but we should look into creating guidance to advise people against using button-styled links in forms and instead use buttons. It has some accessibility/usability implications.
That said, I still think that our CSS should accommodate the pattern in case there is a valid use case. I understand there might be differing opinions on that though.
|
@mejiaj bumping for review when you get the chance! |
mejiaj
left a comment
There was a problem hiding this comment.
Links with usa-button are rendering correctly and regular anchor's aren't affected. Nice work!
How I tested
I modified usa-sign-in-form.twig with the following markup:
// usa-sign-in-form.twig
<input class="usa-button" type="submit" value="{{ submit.label |default('Sign in') }}">
<a href="#" class="usa-button">Testing link with button class</a><br>
<a href="#">A link without usa-link</a><br>
<a href="#" class="usa-link">With usa-link</a><br>Also tested in Safari, Firefox, and Chrome.

Fixed invisible link text for anchors styled as buttons within forms. We specified which form links should not receive
typeset-link. Now link text does not match the primary button color when nested inside of a form and theusa-buttonclass is present.Problem statement
Links styled as buttons inherit
typeset-linkwhen nested within forms. This causes the link text color to match the button background color and becomes unreadable.Solution
By adding
:not(.usa-button)we can avoid links with theusa-buttonclass and preserve the button styles.Related issue
Closes #5066
Testing and review
<a class="usa-button" href="#">Button Text</a>Screenshots
Before:
After
Before opening this PR, make sure you’ve done whichever of these applies to you:
git pull origin [base branch]to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch isdevelop).npm run prettier:scssto format any Sass updates.npm testand confirm that all tests pass.