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

fix: blank field group docs and read-only radio alignment #3164

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jawinn
Copy link
Collaborator

@jawinn jawinn commented Sep 24, 2024

Description

Includes two small fixes:

  1. The field group "Docs" page was blank. It was missing the default arg value for items in its Template, causing nothing to render within the field group markup.
  2. The read-only radios on the field group Docs page were displaying on the completely wrong side. This issue also existed on the Chromatic template for radio. This was because of margin-inline-start being set to auto instead of 0 for read-only. In a flex container, auto on the margin of a flex item will automatically extend its specified margin to occupy the extra space.

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Validation steps

  • Stories on the field group "Docs" page in Storybook are now appearing @marissahuysentruyt
  • Read-only radios in field group are no longer aligned to the right. Fix is visible in VRT changes for field group. @marissahuysentruyt

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

Read-only bug. Previous behavior:
Screenshot 2024-09-24 at 4 26 20 PM

Screenshot 2024-09-24 at 4 25 33 PM

Fixed behavior:
Screenshot 2024-09-24 at 4 45 58 PM

Screenshot 2024-09-24 at 4 47 28 PM

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • ✨ This pull request is ready to merge. ✨

Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: 3054d94

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

This PR includes changesets to release 1 package
Name Type
@spectrum-css/radio Minor

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

Fixes the Docs page for Field group displaying blank, because the
template lost its default arg value for items.
Correct an issue with the alignment of a readonly radio's label element
within field group and flex layouts. The use of `auto` on the margin was
previously pushing the label element all the way to the opposite side
when within a field group.
@jawinn jawinn force-pushed the jawinn/fix-field-group-docs-and-readonly-radio branch from ed577d2 to 3054d94 Compare September 24, 2024 20:53
@jawinn jawinn added the run_vrt For use on PRs looking to kick off VRT label Sep 24, 2024
Copy link
Contributor

github-actions bot commented Sep 24, 2024

🚀 Deployed on https://pr-3164--spectrum-css.netlify.app

Copy link
Contributor

File metrics

Summary

Total size: 4.31 MB*
Total change (Δ): ⬇ 0.01 KB (-0.00%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Δ
radio 17.78 KB ⬇ < 0.01 KB

Details

radio

File Head Base Δ
index-base.css 16.72 KB 16.72 KB ⬇ < 0.01 KB (-0.02%)
index-theme.css 1.67 KB 1.67 KB -
index-vars.css 17.78 KB 17.79 KB ⬇ < 0.01 KB (-0.02%)
index.css 17.78 KB 17.79 KB ⬇ < 0.01 KB (-0.02%)
themes/express.css 1.35 KB 1.35 KB -
themes/spectrum.css 1.35 KB 1.35 KB -
* Size determined by adding together the size of the main file for all packages in the library.
* Results are not gzipped or minified.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

Like you said, 2 for 1! The radio margin-inline-start fix realigns everything properly for ltr and rtl. The only we should do is pass some checkboxes to the checkbox stories! Thanks for cleaning this up!

Comment on lines +67 to +72
(passthroughs, context) => Radio({
...passthroughs,
id: "apple",
label: "Apples are best",
customClasses: ["spectrum-FieldGroup-item"],
}, context),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll have to edit some of the items for certain stories. Right now, all of the checkbox variants are showing radio buttons instead of checkboxes.

Screenshot 2024-09-26 at 9 14 19 AM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, does the toggle for inputType need to do anything else but change the role from radiogroup to group? It's doing that right now, all is good- I just expected it to change the component shown, but that seems like work for another PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Re: only getting radios for control group now--this means our control for radios vs. checkboxes is also out of order (and has been for awhile) 😕 Our template doesn't really support switching based on inputType the way it did before, so I wonder if it'd be necessary to create separate stories for a checkbox group and radio group? That could easily be a separate effort outside of this PR if it doesn't seem doable here though.

Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

Now that you've brought the Docs back on FieldGroup, there are lots of other things going on here with the controls particularly that have my attention. Here's what I've noticed (I already mentioned some of these below):

  • We have a stray label control in the controls
  • We lost the Help text, which maybe is ok (although we are testing it here in Chromatic, so it seems like we ought to keep it), but since that was the only thing that visibly changed when the invalid control is turned on, now the invalid control doesn't appear to do anything.
  • We gained a required control at some point after the docs to storybook for this was completed and that doesn't seem to do anything, I think maybe we just need to pass that arg down to the FieldLabel in the template.
  • Our controls for checkbox/radio don't do anything, we can only see radios
  • The testing preview does show checkboxes and radios but shows checkboxes only with horizontal positioning (and doesn't show radios), do we think this is sufficient to test them? It feels to me like we could be missing something by not testing radios and checkboxes in all positions, but I could be convinced otherwise.

Addressing these separately would definitely be ok as far as I'm concerned since these aren't things that broke in this PR and they weren't in the original scope of the work, so I don't know that all of this needs to be fixed before we merge, but definitely all things we should address with fieldgroup at some point!

Also I'm going to mention the docs to storybook PR for fieldgroup here and link the preview for easy reference in case we want to go back and see how it looked before when it worked: #2827

@@ -62,6 +62,27 @@ export default {
inputType: "radio",
labelPosition: "top",
layout: "vertical",
label: "Select one of the following options:",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a { table: { disable: true } } on fieldLabel in L55 here but I think somewhere along the way the arg changed from fieldLabel to label and now we have a stray label control showing in Storybook that we would probably want to hide:

image

Comment on lines +67 to +72
(passthroughs, context) => Radio({
...passthroughs,
id: "apple",
label: "Apples are best",
customClasses: ["spectrum-FieldGroup-item"],
}, context),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Re: only getting radios for control group now--this means our control for radios vs. checkboxes is also out of order (and has been for awhile) 😕 Our template doesn't really support switching based on inputType the way it did before, so I wonder if it'd be necessary to create separate stories for a checkbox group and radio group? That could easily be a separate effort outside of this PR if it doesn't seem doable here though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review run_vrt For use on PRs looking to kick off VRT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants