Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
heath-freenome authored Aug 31, 2022
2 parents babcc1a + 94bfec8 commit 33f4115
Show file tree
Hide file tree
Showing 4 changed files with 528 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ should change the heading of the (upcoming) version to include a major version b
- Added missing `children` property on the `FormProps` type for `Form`

## @rjsf/antd
- Do not show errors if `extraErrors` has `[]` (https://github.com/rjsf-team/react-jsonschema-form/pull/2576).
- Added support for `schema.examples` in the material ui theme fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/2368, https://github.com/rjsf-team/react-jsonschema-form/issues/2557)

## @rjsf/fluent-ui
Expand Down
6 changes: 4 additions & 2 deletions packages/antd/src/templates/FieldTemplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ const FieldTemplate = ({
colon={colon}
extra={description}
hasFeedback={schema.type !== "array" && schema.type !== "object"}
help={(!!rawHelp && help) || (!!rawErrors && renderFieldErrors())}
help={
(!!rawHelp && help) || (!!rawErrors?.length && renderFieldErrors())
}
htmlFor={id}
label={displayLabel && label}
labelCol={labelCol}
required={required}
style={wrapperStyle}
validateStatus={rawErrors ? "error" : undefined}
validateStatus={rawErrors?.length ? "error" : undefined}
wrapperCol={wrapperCol}
>
{children}
Expand Down
55 changes: 55 additions & 0 deletions packages/antd/test/Array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,59 @@ describe("array fields", () => {
.toJSON();
expect(tree).toMatchSnapshot();
});

test("has errors", () => {
const schema = {
type: "object",
properties: {
name: {
type: "string",
},
},
};
const tree = renderer
.create(
<Form
schema={schema}
validator={validator}
extraErrors={{ name: { __errors: ["Bad input"] } }}
/>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
test("no errors", () => {
const schema = {
type: "object",
properties: {
name: {
type: "string",
},
},
};
const tree = renderer
.create(<Form schema={schema} validator={validator} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
test("empty errors array", () => {
const schema = {
type: "object",
properties: {
name: {
type: "string",
},
},
};
const tree = renderer
.create(
<Form
schema={schema}
validator={validator}
extraErrors={{ name: { __errors: [] } }}
/>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
});
Loading

0 comments on commit 33f4115

Please sign in to comment.