Skip to content

Commit 9a08201

Browse files
authored
Merge pull request #936 from rvsia/mergemaster
Merge master to V3
2 parents bc3bc1e + b6ee83d commit 9a08201

File tree

77 files changed

+2433
-2354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2433
-2354
lines changed

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Issue
3-
about: This is a general issue for Data Driven Forms library.
3+
about: Issues are intended for reporting bugs. If you have questions/ideas or if you need any help, please use Discussions first.
44
title: ''
55
labels: ''
66
assignees: ''

.github/pull_request_template.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Fixes #(issue) *(if applicable)*
2+
3+
**Description**
4+
5+
Please include a summary of the change.
6+
7+
**Schema** *(if applicable)*
8+
9+
```jsx
10+
```
11+
12+
**Checklist:** *(please see [documentation page](https://data-driven-forms.org/development-setup) for more information)*
13+
14+
- [ ] `Yarn build` passes
15+
- [ ] `Yarn lint` passes
16+
- [ ] `Yarn test` passes
17+
- [ ] Test coverage for new code *(if applicable)*
18+
- [ ] Documentation update *(if applicable)*
19+
- [ ] Correct commit message
20+
- format `fix|feat({scope}): {description}`
21+
- i.e. `fix(pf3): wizard correctly handles next button`
22+
- fix will release a new \_.\_.X version
23+
- feat will release a new \_.X.\_ version (use when you introduce new features)
24+
- we want to avoid any breaking changes, please contact us, if there is no way how to avoid them
25+
- scope: package
26+
- if you update the documentation or tests, do not use this format
27+
- i.e. `Fix button on documenation example page`

packages/ant-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/ant-component-mapper",
3-
"version": "2.17.0",
3+
"version": "2.19.1",
44
"description": "Component mapper for Ant Design component mapper form data-driven-forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const validationError = (meta, validateOnMount) => {
22
if (validateOnMount) {
3-
return meta.error;
3+
return meta.error || meta.submitError;
44
}
55

6-
return meta.touched && meta.error;
6+
return meta.touched && (meta.error || meta.submitError);
77
};

packages/ant-component-mapper/src/field-array/field-array.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const DynamicArray = ({ ...props }) => {
134134
...buttonLabels
135135
};
136136

137-
const { dirty, submitFailed, error } = meta;
137+
const { dirty, submitFailed, error, submitError } = meta;
138138
const isError = (dirty || submitFailed) && error && typeof error === 'string';
139139
return (
140140
<FormGroup
@@ -228,10 +228,10 @@ const DynamicArray = ({ ...props }) => {
228228
)}
229229
</Row>
230230
</Col>
231-
{isError && (
231+
{(isError || submitError) && (
232232
<Col span={12}>
233233
<Typography.Text type="danger" {...ErrorMessageProps}>
234-
{typeof error === 'object' ? error.name : error}
234+
{typeof error === 'object' ? error.name : error || submitError}
235235
</Typography.Text>
236236
</Col>
237237
)}

packages/ant-component-mapper/src/tests/components.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('formFields generated tests', () => {
1515
FormTemplate={(props) => <FormTemplate {...props} />}
1616
schema={schema}
1717
componentMapper={componentMapper}
18+
subscription={{ submitFailed: true }}
1819
{...props}
1920
/>
2021
);
@@ -288,6 +289,21 @@ describe('formFields generated tests', () => {
288289
).toEqual(true);
289290
}
290291
});
292+
293+
it('renders with submitError', async () => {
294+
const wrapper = mount(<RendererWrapper schema={schema} onSubmit={() => ({ [field.name]: errorText })} />);
295+
await act(async () => {
296+
wrapper.find('form').simulate('submit');
297+
});
298+
wrapper.update();
299+
expect(
300+
wrapper
301+
.find('.ant-form-item-explain')
302+
.last()
303+
.text()
304+
).toEqual(errorText);
305+
expect(wrapper.find('.ant-form-item-has-error').length).toBeGreaterThanOrEqual(1);
306+
});
291307
});
292308
});
293309
});

packages/blueprint-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/blueprint-component-mapper",
3-
"version": "2.17.0",
3+
"version": "2.19.1",
44
"description": "Blueprint component mapper for data-driven-forms.",
55
"main": "index.js",
66
"module": "esm/index.js",

packages/blueprint-component-mapper/src/field-array/field-array.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const FieldArray = (props) => {
6868

6969
const { required } = useContext(BlueprintContext);
7070

71-
const { error, touched } = meta;
72-
const showError = (validateOnMount || touched) && error;
71+
const { error, touched, submitError } = meta;
72+
const showError = (validateOnMount || touched) && (error || submitError);
7373

7474
const text = showError ? error : helperText || description;
7575

packages/blueprint-component-mapper/src/form-group/form-group.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const FormGroupInternal = ({
2222
}) => {
2323
const { required } = useContext(BlueprintContext);
2424

25-
const { error, touched, warning } = meta;
26-
const showError = (validateOnMount || touched) && error;
25+
const { error, touched, warning, submitError } = meta;
26+
const showError = (validateOnMount || touched) && (error || submitError);
2727
const showWarning = (validateOnMount || touched) && warning;
2828

2929
const text = showError || showWarning || helperText || description;

packages/blueprint-component-mapper/src/tests/components.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('formFields generated tests', () => {
1515
FormTemplate={(props) => <FormTemplate {...props} />}
1616
schema={schema}
1717
componentMapper={componentMapper}
18+
subscription={{ submitFailed: true }}
1819
{...props}
1920
/>
2021
);
@@ -263,6 +264,18 @@ describe('formFields generated tests', () => {
263264
}
264265
}
265266
});
267+
268+
it('renders with error', () => {
269+
const wrapper = mount(<RendererWrapper schema={schema} onSubmit={() => ({ [field.name]: errorText })} />);
270+
wrapper.find('form').simulate('submit');
271+
expect(
272+
wrapper
273+
.find('.bp3-form-helper-text')
274+
.last()
275+
.text()
276+
).toEqual(errorText);
277+
expect(wrapper.find('.bp3-intent-danger').length).toBeGreaterThanOrEqual(1);
278+
});
266279
});
267280
});
268281
});

0 commit comments

Comments
 (0)