Skip to content

Commit 30e4f1e

Browse files
committed
Fixes rjsf-team#220: Fixed ui:help generated semantics.
1 parent 1eeaa8a commit 30e4f1e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"gh-pages": "^0.11.0",
5757
"html": "0.0.10",
5858
"jsdom": "^8.3.0",
59-
"mocha": "^2.3.0",
59+
"mocha": "^2.5.3",
6060
"react": "^15.0.0",
6161
"react-addons-test-utils": "^15.0.1",
6262
"react-codemirror": "^0.2.3",

src/components/fields/SchemaField.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ function getLabel(label, required, id) {
4545
);
4646
}
4747

48+
function renderHelp(help) {
49+
if (!help) {
50+
return null;
51+
}
52+
if (typeof help === "string") {
53+
return <p className="help-block">{help}</p>;
54+
}
55+
return <div className="help-block">{help}</div>;
56+
}
57+
4858
function ErrorList({errors}) {
4959
return (
5060
<div>
@@ -87,7 +97,7 @@ function Wrapper({
8797
{displayLabel && label ? getLabel(label, required, id) : null}
8898
{children}
8999
{isError ? <ErrorList errors={errors} /> : <div/>}
90-
{help ? <p className="help-block">{help}</p> : null}
100+
{renderHelp(help)}
91101
</div>
92102
);
93103
}

test/uiSchema_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("uiSchema", () => {
113113

114114
const {node} = createFormComponent({schema, uiSchema});
115115

116-
expect(node.querySelector(".help-block").textContent).eql("plop");
116+
expect(node.querySelector("p.help-block").textContent).eql("plop");
117117
});
118118

119119
it("should accept a react element as help", () => {
@@ -122,7 +122,7 @@ describe("uiSchema", () => {
122122

123123
const {node} = createFormComponent({schema, uiSchema});
124124

125-
expect(node.querySelector(".help-block").textContent).eql("plop");
125+
expect(node.querySelector("div.help-block").textContent).eql("plop");
126126
});
127127
});
128128

0 commit comments

Comments
 (0)