Skip to content

Commit 9e119fc

Browse files
bradhughepicfaace
andauthored
Help elements need a predictable ID (rjsf-team#2360)
* Help elements need a predictable ID * Updated help id in semantic-ui theme Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
1 parent effe15d commit 9e119fc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/core/src/components/fields/SchemaField.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,22 @@ function LabelInput(props) {
8585
}
8686

8787
function Help(props) {
88-
const { help } = props;
88+
const { id, help } = props;
8989
if (!help) {
9090
return null;
9191
}
9292
if (typeof help === "string") {
93-
return <p className="help-block">{help}</p>;
93+
return (
94+
<p id={id} className="help-block">
95+
{help}
96+
</p>
97+
);
9498
}
95-
return <div className="help-block">{help}</div>;
99+
return (
100+
<div id={id} className="help-block">
101+
{help}
102+
</div>
103+
);
96104
}
97105

98106
function ErrorList(props) {
@@ -316,7 +324,7 @@ function SchemaFieldRender(props) {
316324
/>
317325
),
318326
rawDescription: description,
319-
help: <Help help={help} />,
327+
help: <Help id={id + "__help"} help={help} />,
320328
rawHelp: typeof help === "string" ? help : undefined,
321329
errors: <ErrorList errors={errors} />,
322330
rawErrors: errors,

packages/semantic-ui/src/FieldTemplate/FieldTemplate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function FieldTemplate({
3131
)}
3232
</MaybeWrap>
3333
)}
34-
<HelpField helpText={rawHelp} id={id} />
34+
<HelpField helpText={rawHelp} id={id + "__help"} />
3535
<RawErrors errors={rawErrors} options={errorOptions} />
3636
</MaybeWrap>
3737
</Form.Group>

0 commit comments

Comments
 (0)