Skip to content

Commit 134e639

Browse files
Merge pull request #18226 from Yoast/P1-1270-no-label-formfield-a11y
P1 1270 no label formfield a11y
2 parents f1fa13b + d4e57e5 commit 134e639

14 files changed

Lines changed: 19 additions & 17 deletions

File tree

packages/ui-library/src/components/checkbox-group/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ CheckboxGroup.propTypes = {
6262
id: PropTypes.string.isRequired,
6363
name: PropTypes.string.isRequired,
6464
values: PropTypes.arrayOf( PropTypes.string ),
65-
label: PropTypes.node,
65+
label: PropTypes.node.isRequired,
6666
options: PropTypes.arrayOf( PropTypes.shape( {
6767
value: PropTypes.string.isRequired,
6868
label: PropTypes.string.isRequired,
@@ -74,7 +74,6 @@ CheckboxGroup.propTypes = {
7474
CheckboxGroup.defaultProps = {
7575
children: null,
7676
values: [],
77-
label: null,
7877
className: "",
7978
};
8079

packages/ui-library/src/components/checkbox-group/stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Factory.args = {
4141
{ value: "3", label: "Option 3" },
4242
{ value: "4", label: "Option 4" },
4343
],
44+
label: "A Checkbox Group",
4445
};
4546

4647
export const WithLabelAndDescription = Template.bind();

packages/ui-library/src/components/radio-group/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ RadioGroup.propTypes = {
7474
id: PropTypes.string.isRequired,
7575
name: PropTypes.string.isRequired,
7676
value: PropTypes.string.isRequired,
77-
label: PropTypes.node,
77+
label: PropTypes.node.isRequired,
7878
options: PropTypes.arrayOf( PropTypes.shape( {
7979
value: PropTypes.string.isRequired,
8080
label: PropTypes.string.isRequired,
@@ -86,7 +86,6 @@ RadioGroup.propTypes = {
8686

8787
RadioGroup.defaultProps = {
8888
children: null,
89-
label: null,
9089
variant: "default",
9190
className: "",
9291
};

packages/ui-library/src/components/radio-group/stories.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Factory.args = {
4343
{ value: "3", label: "Option 3" },
4444
{ value: "4", label: "Option 4" },
4545
],
46+
label: "A Radio Group",
4647
};
4748

4849
export const Variants = ( args ) => (
@@ -57,14 +58,15 @@ export const Variants = ( args ) => (
5758
{ value: "3", label: "Option 3" },
5859
{ value: "4", label: "Option 4" },
5960
] }
61+
label="Default Radio Group"
6062
onChange={ noop }
6163
/>
6264
<hr />
6365
<RadioGroup
6466
id="radio-group-2"
6567
name="name-2"
6668
value="2"
67-
label="Radio group with a label"
69+
label="Inline-block Radio Group"
6870
options={ [
6971
{ value: "1", label: "1" },
7072
{ value: "2", label: "2" },

packages/ui-library/src/components/select-field/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ SelectField.propTypes = {
5454
id: PropTypes.string.isRequired,
5555
name: PropTypes.string.isRequired,
5656
value: PropTypes.string,
57-
label: PropTypes.node,
57+
label: PropTypes.node.isRequired,
5858
options: PropTypes.arrayOf( PropTypes.shape( {
5959
value: PropTypes.string.isRequired,
6060
label: PropTypes.string.isRequired,
@@ -67,7 +67,6 @@ SelectField.propTypes = {
6767
SelectField.defaultProps = {
6868
children: null,
6969
value: undefined,
70-
label: null,
7170
error: null,
7271
className: "",
7372
};

packages/ui-library/src/components/select-field/stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Factory.args = {
4444
{ value: "3", label: "Option 3" },
4545
{ value: "4", label: "Option 4" },
4646
],
47+
label: "A Select Field",
4748
};
4849

4950
export const WithLabelAndDescription = Template.bind( {} );

packages/ui-library/src/components/text-field/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ const TextField = ( {
5454
TextField.propTypes = {
5555
id: PropTypes.string.isRequired,
5656
onChange: PropTypes.func.isRequired,
57-
label: PropTypes.node,
57+
label: PropTypes.node.isRequired,
5858
className: PropTypes.string,
5959
description: PropTypes.node,
6060
error: PropTypes.node,
6161
};
6262

6363
TextField.defaultProps = {
64-
label: null,
6564
className: "",
6665
description: null,
6766
error: null,

packages/ui-library/src/components/text-field/stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
args: {
2121
id: "input-field",
2222
onChange: noop,
23+
label: "A Text Field",
2324
},
2425
};
2526

packages/ui-library/src/components/textarea-field/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ const TextareaField = ( {
5151

5252
TextareaField.propTypes = {
5353
id: PropTypes.string.isRequired,
54-
label: PropTypes.node,
54+
label: PropTypes.node.isRequired,
5555
className: PropTypes.string,
5656
description: PropTypes.node,
5757
error: PropTypes.node,
5858
};
5959

6060
TextareaField.defaultProps = {
61-
label: null,
6261
className: "",
6362
description: null,
6463
error: null,

packages/ui-library/src/components/textarea-field/stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
},
1818
args: {
1919
id: "textarea-field",
20+
label: "A Textarea Field",
2021
},
2122
};
2223

0 commit comments

Comments
 (0)