Skip to content
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 - Bug: Validation requires alerts with icons for correct success mark alignment #5236

Open
2 tasks done
grubersjoe opened this issue Apr 14, 2023 · 1 comment
Open
2 tasks done
Labels
Needs: Discussion We need to discuss an approach to this issue Package: Validation Role: Dev Development/engineering skills needed Type: Bug A problem in the code

Comments

@grubersjoe
Copy link

grubersjoe commented Apr 14, 2023

Describe the bug

When using the usa-validation component the horizontal alignment of success marks in the usa-checklist breaks if you use the usa-alert--no-icon class for the parent usa-alert. Success marks are rendered too far left at the edge of the alert box. See the screenshot.

Steps to reproduce the bug

<label
  class="usa-label"
  for="password"
>
  Code
</label>
<input
  id="password"
  class="usa-input"
  name="password"
  type="text"
  minlength="3"
  maxlength="3"
  pattern="^\d{3}$"
  required
  autocomplete="new-password"
  data-validation-element="#validate-code"
  data-validate-numbers="^\d{3}$"
  aria-describedby="validate-code"
/>

<!-- Note the usa-alert--no-icon class -->
<div class="usa-alert usa-alert--info usa-alert--no-icon usa-alert--validation">
  <div class="usa-alert__body">
    <h3 class="usa-alert__heading margin-bottom-3">Requirements</h3>
    <ul
      id="validate-code"
      class="usa-checklist"
    >
      <li
        class="usa-checklist__item"
        data-validator="numbers"
      >
        Exactly three numbers
      </li>
    </ul>
  </div>
</div>

Expected Behavior

I'm not sure if using an alert with icon is expected for the validation component but the documentation gives no hints about such a requirement. Consequently, I would expect that the success mark alignment works in either case: with and without icons in the parent alert (setting the usa-alert--no-icon class).

Related code

I've added this rule to my CSS to work around the issue:

.usa-alert--no-icon.usa-alert--validation .usa-checklist {
  padding-left: units(5);
}

Screenshots

Without an icon the alignment breaks:
image

With default alerts alignment is correct:
image

System setup

USWDS v3.4.1
mac OS Ventura
Chrome v112

Additional context

No response

Code of Conduct

@grubersjoe grubersjoe added Needs: Confirmation We need to confirm that this is an issue Status: Triage We're triaging this issue and grooming if necessary Type: Bug A problem in the code labels Apr 14, 2023
@brunerae brunerae added the Role: Dev Development/engineering skills needed label May 4, 2023
@thisisdano thisisdano removed the Status: Triage We're triaging this issue and grooming if necessary label Jun 1, 2023
@amyleadem
Copy link
Contributor

Confirming that using the "No icon" alert variant causes misalignment on the validation component. The code below created the following presentation:

image

      <form class="usa-form">
        <fieldset class="usa-fieldset">
          <legend class="usa-legend usa-legend--large">Enter a code</legend>
          <div class="usa-alert usa-alert--info usa-alert--no-icon usa-alert--validation">
            <div class="usa-alert__body">
              <h3 class="usa-alert__heading">Code requirements</h3>
              <ul class="usa-checklist" id="validate-code">
                <li class="usa-checklist__item" data-validator="uppercase">
                  Use at least one uppercase character
                </li>
                <li class="usa-checklist__item" data-validator="numerical">
                  Use at least one number
                </li>
              </ul>
            </div>
          </div>
          <label class="usa-label" for="code">Code</label>
          <input
            class="usa-input"
            id="code"
            name="code"
            data-validate-uppercase="[A-Z]"
            data-validate-numerical="\d"
            data-validation-element="validate-code"
          />
          <input class="usa-button" type="submit" value="Submit code" />
        </fieldset>
      </form>

We should discuss if we want users to be able to choose any variant of the alert when using the validation component.

@amyleadem amyleadem added Needs: Discussion We need to discuss an approach to this issue Package: Validation and removed Needs: Confirmation We need to confirm that this is an issue Package: Checklist labels Jun 5, 2023
@amyleadem amyleadem changed the title USWDS - Bug: usa-checklist (usa-validation) requires alerts with icons for correct success mark alignment USWDS - Bug: Validation requires alerts with icons for correct success mark alignment Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Discussion We need to discuss an approach to this issue Package: Validation Role: Dev Development/engineering skills needed Type: Bug A problem in the code
Projects
Status: Needs refinement
Development

No branches or pull requests

5 participants