Skip to content

Commit ebd2cb4

Browse files
authored
Merge pull request #1464 from salesforce-ux/check-error
Associate radios and checkboxes with their error messages
2 parents 1c4b688 + 8ddf450 commit ebd2cb4

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

ui/components/forms/flavors/checkbox-alternate/index.react.example.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let CheckboxGroup = props =>
3737

3838
let Checkbox = props =>
3939
<span className={className(pf('button checkbox--button'), props.className)} htmlFor={props.id}>
40-
<input name="checkbox" type="checkbox" id={props.id} disabled={props.disabled} />
40+
<input name="checkbox" type="checkbox" id={props.id} disabled={props.disabled} aria-describedby={props.errorId} />
4141
<label className={pf('checkbox--button__label')} htmlFor={props.id}>
4242
<span className={pf('checkbox--faux')}>
4343
{props.children}
@@ -66,13 +66,13 @@ let StateB = props =>
6666
<Demo>
6767
<Fieldset className={pf('has-error')}>
6868
<CheckboxGroup>
69-
<Checkbox id="monday">Mon</Checkbox>
70-
<Checkbox id="tuesday">Tue</Checkbox>
71-
<Checkbox id="wednesday">Wed</Checkbox>
72-
<Checkbox id="thursday">Thu</Checkbox>
73-
<Checkbox id="friday">Fri</Checkbox>
69+
<Checkbox errorId="error_01" id="monday">Mon</Checkbox>
70+
<Checkbox errorId="error_01" id="tuesday">Tue</Checkbox>
71+
<Checkbox errorId="error_01" id="wednesday">Wed</Checkbox>
72+
<Checkbox errorId="error_01" id="thursday">Thu</Checkbox>
73+
<Checkbox errorId="error_01" id="friday">Fri</Checkbox>
7474
</CheckboxGroup>
75-
<div className={pf('form-element__help')}>This field is required</div>
75+
<div id="error_01" className={pf('form-element__help')}>This field is required</div>
7676
</Fieldset>
7777
</Demo>;
7878

ui/components/forms/flavors/checkbox-toggle/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464
}
6565

66-
&:focus {
66+
&:focus {
6767

6868
& + .#{$css-prefix}checkbox--faux,
6969
& ~ .#{$css-prefix}checkbox--faux,

ui/components/forms/flavors/checkbox/index.react.example.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export let Checkbox = props => {
5050
return (
5151
<span className={pf('checkbox')}>
5252
{props.children}
53-
<input type="checkbox" name="options" id={ props.id ? props.id : uniqueId } disabled={props.disabled} defaultChecked={props.checked} />
53+
<input type="checkbox" name="options" id={ props.id ? props.id : uniqueId } disabled={props.disabled} defaultChecked={props.checked} aria-describedby={props.errorId} />
5454
<label className={className(pf('checkbox__label'), props.className)} htmlFor={ props.id ? props.id : uniqueId }>
5555
<span className={pf('checkbox--faux')}></span>
5656
<span className={className(pf('form-element__label'), props.hideLabel ? pf('assistive-text') : null)}>{props.label}</span>
@@ -94,9 +94,9 @@ let ErrorState = props =>
9494
<Demo>
9595
<FormElement className={pf('is-required has-error')}>
9696
<FormElementControl>
97-
<Checkbox label="Checkbox Label"><abbr className={pf('required')} title="required">*</abbr></Checkbox>
97+
<Checkbox label="Checkbox Label" errorId="error_01"><abbr className={pf('required')} title="required">*</abbr></Checkbox>
9898
</FormElementControl>
99-
<div className={pf('form-element__help')} iref="form-element__help">This field is required</div>
99+
<div id="error_01" className={pf('form-element__help')} iref="form-element__help">This field is required</div>
100100
</FormElement>
101101
</Demo>;
102102

@@ -136,10 +136,10 @@ let GroupError = props =>
136136
<Fieldset className={pf('is-required has-error')}>
137137
<Legend><abbr className={pf('required')} title="required">*</abbr> Checkbox Group Label</Legend>
138138
<FormElementControl>
139-
<Checkbox label="Checkbox Label" checked />
140-
<Checkbox label="Checkbox Label" />
139+
<Checkbox errorId="error_01" label="Checkbox Label" checked />
140+
<Checkbox errorId="error_01" label="Checkbox Label" />
141141
</FormElementControl>
142-
<div className={pf('form-element__help')} iref="form-element__help">This field is required</div>
142+
<div id="error_01" className={pf('form-element__help')} iref="form-element__help">This field is required</div>
143143
</Fieldset>
144144
</Demo>;
145145

ui/components/forms/flavors/radio-group-alternate/index.react.example.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let RadioGroup = props =>
3737

3838
let Radio = props =>
3939
<span className={className(pf('button radio--button'), props.className)}>
40-
<input name="radio" type="radio" id={props.id} disabled={props.disabled} />
40+
<input name="radio" type="radio" id={props.id} disabled={props.disabled} aria-describedby={props.errorId} />
4141
<label className={pf('radio--button__label')} htmlFor={props.id}>
4242
<span className={pf('radio--faux')}>
4343
{props.children}
@@ -66,13 +66,13 @@ let StateB = props =>
6666
<Demo>
6767
<Fieldset className={pf('has-error')}>
6868
<RadioGroup>
69-
<Radio id="monday">Mon</Radio>
70-
<Radio id="tuesday">Tue</Radio>
71-
<Radio id="wednesday">Wed</Radio>
72-
<Radio id="thursday">Thu</Radio>
73-
<Radio id="friday">Fri</Radio>
69+
<Radio errorId="error_01" id="monday">Mon</Radio>
70+
<Radio errorId="error_01" id="tuesday">Tue</Radio>
71+
<Radio errorId="error_01" id="wednesday">Wed</Radio>
72+
<Radio errorId="error_01" id="thursday">Thu</Radio>
73+
<Radio errorId="error_01" id="friday">Fri</Radio>
7474
</RadioGroup>
75-
<div className={pf('form-element__help')}>This field is required</div>
75+
<div id="error_01" className={pf('form-element__help')}>This field is required</div>
7676
</Fieldset>
7777
</Demo>;
7878

ui/components/forms/flavors/radio/index.react.example.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export let Radio = props => {
4141

4242
return (
4343
<span className={pf('radio')}>
44-
<input type="radio" id={ uniqueId } name="options" disabled={props.disabled} defaultChecked={props.checked} />
44+
<input type="radio" id={ uniqueId } name="options" disabled={props.disabled} defaultChecked={props.checked} aria-describedby={props.errorId} />
4545
<label className={pf('radio__label')} htmlFor={ uniqueId }>
4646
<span className={pf('radio--faux')}></span>
4747
<span className={pf('form-element__label')}>{props.children}</span>
@@ -81,10 +81,10 @@ let ErrorState = props =>
8181
<Fieldset className={pf('is-required has-error')}>
8282
<Legend><abbr className={pf('required')} title="required">*</abbr> Radio Group Label</Legend>
8383
<FormElementControl>
84-
<Radio checked>Radio Label One</Radio>
85-
<Radio>Radio Label Two</Radio>
84+
<Radio errorId="error_01" checked>Radio Label One</Radio>
85+
<Radio errorId="error_01">Radio Label Two</Radio>
8686
</FormElementControl>
87-
<div className={pf('form-element__help')} iref="form-element__help">This field is required</div>
87+
<div id="error_01" className={pf('form-element__help')} iref="form-element__help">This field is required</div>
8888
</Fieldset>
8989
</Demo>;
9090

0 commit comments

Comments
 (0)