Skip to content

Commit e4003a4

Browse files
authored
fix(field-group): addresses regressions in field groups. (#3227)
* fix(field-group): fix fieldgroup template rendering logic - reverts story file - moves rendering logic to template file allowing story controls to update input type - add placeholder input content to template * fix(field-group): pass isRequired through to FieldLabel * fix(field-group): update indentation + field description * fix(field-group): adjust label casing
1 parent dc94a68 commit e4003a4

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

components/fieldgroup/stories/fieldgroup.stories.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { disableDefaultModes } from "@spectrum-css/preview/modes";
22
import { isInvalid, isReadOnly, isRequired } from "@spectrum-css/preview/types";
33
import { default as RadioSettings } from "@spectrum-css/radio/stories/radio.stories.js";
4-
import { Template as Radio } from "@spectrum-css/radio/stories/template.js";
54
import metadata from "../metadata/metadata.json";
65
import packageJson from "../package.json";
76
import { FieldGroupSet } from "./fieldgroup.test.js";
@@ -21,6 +20,11 @@ export default {
2120
title: "Field group",
2221
component: "FieldGroup",
2322
argTypes: {
23+
label: {
24+
name: "Label",
25+
description: "The label for the field group component.",
26+
type: { name: "string" },
27+
},
2428
inputType: {
2529
name: "Input type",
2630
type: { name: "string" },
@@ -63,26 +67,24 @@ export default {
6367
inputType: "radio",
6468
labelPosition: "top",
6569
layout: "vertical",
66-
label: "Select one of the following options:",
70+
label: "Field group label",
71+
helpText: "Select an option.",
6772
items: [
68-
(passthroughs, context) => Radio({
69-
...passthroughs,
73+
{
7074
id: "apple",
7175
label: "Apples are best",
7276
customClasses: ["spectrum-FieldGroup-item"],
73-
}, context),
74-
(passthroughs, context) => Radio({
75-
...passthroughs,
77+
},
78+
{
7679
id: "banana",
7780
label: "Bananas forever",
7881
customClasses: ["spectrum-FieldGroup-item"],
79-
}, context),
80-
(passthroughs, context) => Radio({
81-
...passthroughs,
82+
},
83+
{
8284
id: "pear",
8385
label: "Pears or bust",
8486
customClasses: ["spectrum-FieldGroup-item"],
85-
}, context),
87+
}
8688
],
8789
isInvalid: false,
8890
isRequired: false,

components/fieldgroup/stories/template.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { Template as CheckBox } from "@spectrum-css/checkbox/stories/template.js";
12
import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js";
23
import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js";
3-
import { renderContent } from "@spectrum-css/preview/decorators";
4+
import { Template as Radio } from "@spectrum-css/radio/stories/template.js";
45
import { html } from "lit";
56
import { classMap } from "lit/directives/class-map.js";
67
import { ifDefined } from "lit/directives/if-defined.js";
@@ -43,6 +44,7 @@ export const Template = (
4344
{
4445
size: "m",
4546
label,
47+
isRequired,
4648
alignment: labelPosition === "side" ? "right" : "top",
4749
},
4850
context,
@@ -53,7 +55,23 @@ export const Template = (
5355
[`${rootClass}InputLayout`]: true,
5456
})}
5557
>
56-
${renderContent(items, { args: { isReadOnly, isRequired }, context })}
58+
${inputType === "radio" ?
59+
items.map((item) =>
60+
Radio({
61+
...item,
62+
isReadOnly,
63+
isRequired,
64+
name: "field-group-example",
65+
customClasses: [`${rootClass}-item`],
66+
}, context))
67+
: items.map((item) =>
68+
CheckBox({
69+
...item,
70+
isReadOnly,
71+
isRequired,
72+
customClasses: [`${rootClass}-item`],
73+
}, context)
74+
)}
5775
${when(helpText, () =>
5876
HelpText(
5977
{

0 commit comments

Comments
 (0)