brand icon indicating copy to clipboard operation
brand copied to clipboard

Fix checkbox and radio input validation positioning

Open MelissaPastore opened this issue 1 year ago • 3 comments

Summary

Ref: https://github.com/primer/brand/issues/203

This PR fixes a bug with the positioning of the validation message for checkbox and radio inputs inside a FormControl component. This was originally reported as just an issue for checkboxes, but I also noticed it impacted radio inputs as well, so this PR fixes the issue for both types of inputs.

List of notable changes:

  • updated the .FormControl--checkbox css class to use flex-grid styling instead of flexbox with row-reverse
  • added FormControl-validation-checkbox css class to position the validation message for checkboxes and radio buttons.
  • added the FormControl-validation-checkbox class to any FormControlValidation children only when there is a checkbox or radio input.
  • added a storybook story for validation with checkbox and radio inputs to illustrate what these scenarios look like.
  • updated the CSS classes for the wrappers for radio and checkbox inputs to conditionally use the grid-row property when their parent element is a form control element.

What should reviewers focus on?

  • What do you think of this approach of using CSS to fix this issue? I saw there was a previous PR that made an attempt to modify the FormControl component's composition and place a container around the input and its label so the validation message would no longer share a parent with them and therefore not be affected by the row-reverse property on the parent container. This CSS only approach seemed a little simpler.

Steps to test:

  1. Open the FormControl component in CI-deployed preview environment
  2. Go to 'w/ Error Validation with Checkbox - Playground' and 'w/ Error Validation with Radio - Playground' story in Storybook
  3. Verify that the validation now appears below the checkbox and radio inputs instead of next to them.

Supporting resources (related issues, external links, etc):

  • Related issue: https://github.com/primer/brand/issues/203
  • Previous PR that attempted to fix this issue: https://github.com/primer/brand/pull/513

Contributor checklist:

  • [ ] All new and existing CI checks pass
  • [ ] Tests prove that the feature works and covers both happy and unhappy paths
  • [ ] Any drop in coverage, breaking changes or regressions have been documented above
  • [ ] New visual snapshots have been generated / updated for any UI changes
  • [ ] All developer debugging and non-functional logging has been removed
  • [ ] Related issues have been referenced in the PR description

Reviewer checklist:

  • [ ] Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • [ ] Check that tests prove the feature works and covers both happy and unhappy paths
  • [ ] Check that there aren't other open Pull Requests for the same update/change

Screenshots:

Please try to provide before and after screenshots or videos

Before After

MelissaPastore avatar Sep 03 '24 21:09 MelissaPastore

🦋 Changeset detected

Latest commit: 073ec821d10e1b32b36bebd8468d1be1ebd035b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Sep 03 '24 21:09 changeset-bot[bot]

🟢 No design token changes found

github-actions[bot] avatar Sep 03 '24 21:09 github-actions[bot]

⚠️ Visual differences found

Our visual comparison tests found UI differences.

Please review the differences by using the test artifacts to ensure that the changes were intentional.

Artifacts can be downloaded and reviewed locally.

Download links are available at the bottom of the workflow summary screen.

Example:

artifacts section of workflow run

If the changes are expected, please run npm run test:visual:update-snapshots to replace the previous fixtures.

Review visual differences

github-actions[bot] avatar Sep 03 '24 21:09 github-actions[bot]

@rezrah @joshfarrant I think this is ready for another review. @rezrah and I discussed isolating the changes to just the checkbox inputs, so I made those changes and incorporated all of the previous feedback as well.

MelissaPastore avatar Oct 14 '24 15:10 MelissaPastore

Thanks again @MelissaPastore!

joshfarrant avatar Oct 16 '24 08:10 joshfarrant