Skip to content

Commit 56f6a92

Browse files
committed
feat(app-rfi): add legend to fieldset for accessible form group labeling
UDS-2042
1 parent ebd1e90 commit 56f6a92

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/app-rfi/src/components/controls/RfiRadioGroup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Field } from "formik";
55
import PropTypes from "prop-types";
66
import React from "react";
77

8-
import { RfiError, RfiLabel } from "./controls-helpers";
8+
import {RfiError, RfiLabel, RfiLegend} from "./controls-helpers";
99

1010
const RfiRadioGroup = ({ name, id, options, label, onBlur }) => {
1111
return (
@@ -19,7 +19,7 @@ const RfiRadioGroup = ({ name, id, options, label, onBlur }) => {
1919
const isError = meta.error;
2020
return (
2121
<fieldset>
22-
<RfiLabel label={label} name={name} id={id} />
22+
<RfiLegend label={label} />
2323
<RfiError isError={isError} metaError={meta.error} />
2424
{options.map(option => (
2525
<div

packages/app-rfi/src/components/controls/controls-helpers.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ const RfiLabel = ({ label, name, id, requiredIcon }) => (
2727
</label>
2828
);
2929

30+
const RfiLegend = ({ label, requiredIcon }) => (
31+
<legend className="fw-bold">
32+
{requiredIcon ? (
33+
<span title="Required">
34+
<i className="fas fa-circle uds-field-required" aria-hidden="true" />
35+
</span>
36+
) : null}
37+
&nbsp;
38+
{label}
39+
</legend>
40+
);
41+
3042
const RfiError = ({ isError, metaError }) => (
3143
<div role="alert">
3244
{isError ? (
@@ -64,4 +76,4 @@ RfiError.propTypes = {
6476
isError: PropTypes.bool,
6577
metaError: PropTypes.string,
6678
};
67-
export { RfiLabel, RfiError, GaEventPropTypes };
79+
export { RfiLabel, RfiLegend, RfiError, GaEventPropTypes };

0 commit comments

Comments
 (0)