Skip to content

Commit c81ccfb

Browse files
Chore: Convert ArrayField to functional components (rjsf-team#4808)
* Chore: Convert ArrayField to functional components The work to convert `ArrayField` to stateless funcitonal components with some breaking changes - In `@rjsf/utils`: - BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplateType` to replace the `onAddIndexClick()`, `onCopyIndexClick()`, `onDropIndexClick()` and `onReorderClick()` callback-generator props with the `onAddItem()`, `onCopyItem()`, `onMoveUpItem()`, `onMoveDownItem()` and `onRemoveItem()` callback props - BREAKING CHANGE: Updated `ArrayFieldItemTemplateType` to change `key: string` to `itemKey: string` to avoid a name collision with React - BREAKING CHANGE: Updated `ArrayFieldTemplateProps` to change the type of the `items` prop from `ArrayFieldItemTemplateType<T, S, F>[]` to `ReactElement[]` - In `@rjsf/core`: - Updated `ArrayField` to refactor code from a class component to seven stateless functional components, replacing the 4 generator-props with the 5 memoized props mentioned in the `@rjsf/utils` changes - BREAKING CHANGE: The refactor included rendering the `ArrayFieldItemTemplate` directly by the `ArrayField` rather than deferring it to the `ArrayFieldTemplate` - Updated the `ArrayField` tests to adjust for the rendering change AND to remove 2 tests due to them no longer being valid - BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes - BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplate` to replace the old callback-generator functions with the new memoizable callback functions - In the rest of the themes, updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes - Updated the `customArray` sample to refactor out a `ArrayFieldItemButtonsTemplate` - Updated the `custom-templates.md` documentation to reflect the `ArrayField` conversion changes - Updated the `v6.x upgrade guide.md` documentation to add the BREAKING CHANGES to the `ArrayFieldTemplateProps`, `ArrayFieldItemTemplateType` and `ArrayFieldItemButtonsTemplateType` - Updated the `CHANGELOG.md` accordingly # Conflicts: # CHANGELOG.md # packages/core/src/components/fields/ArrayField.tsx * - Updated documentation * - Responded to self feedback * - Fixed documentation * Update packages/docs/docs/migration-guides/v6.x upgrade guide.md * - Fixed a bug in `Form` to avoid getting errors being reported at the root level via `onChange` when there aren't * - Picked up the name generator changes * - Reviewer feedback Co-authored-by: Nick Grosenbacher <[email protected]> * - Fixed lint errors --------- Co-authored-by: Nick Grosenbacher <[email protected]>
1 parent 73300b0 commit c81ccfb

File tree

33 files changed

+1347
-1351
lines changed

33 files changed

+1347
-1351
lines changed

CHANGELOG.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,99 @@ should change the heading of the (upcoming) version to include a major version b
2020
## @rjsf/antd
2121

2222
- Updated most of the widgets to get `formContext` from the `registry` instead of the `props` since it will no longer be passed
23-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
23+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
2424
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
25+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
2526

2627
## @rjsf/chakra-ui
2728

28-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
29+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
2930
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
31+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
3032

3133
## @rjsf/core
3234

3335
- Updated `MultiSchemaField` and `SchemaField` to properly display `anyOf`/`oneOf` optional data fields by hiding the label and selector control when it is an optional field AND there is no form data
3436
- Updated `ArrayField`, `BooleanField`, `LayoutMultiSchemaField`, `MultiSchemaField`, `ObjectField`, `SchemaField`, `StringField` and `BaseInputTemplate` to remove `formContext` from the props
3537
- Updated `ObjectField` to refactor the code from a class component to two stateless functional components, replacing the 3 generator-props with the 4 memoized props mentioned in the `@rjsf/utils` changes
3638
- Updated `Form` to "memoize" the `fieldPathId` and `registry` into the `FormState`, adding a `toIChangeEvent()` helper to restrict the state returned on the `IChangeEvent` interface callbacks
37-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
39+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
3840
- Added `nameGenerator` prop to `Form` component to enable custom HTML `name` attribute generation for form fields
41+
- Updated `ArrayField` to refactor code from a class component to seven stateless functional components, replacing the 4 generator-props with the 5 memoized props mentioned in the `@rjsf/utils` changes
42+
- BREAKING CHANGE: The refactor included rendering the `ArrayFieldItemTemplate` directly by the `ArrayField` rather than deferring it to the `ArrayFieldTemplate`
43+
- Updated the `ArrayField` tests to adjust for the rendering change AND to remove 2 tests due to them no longer being valid
44+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
45+
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplate` to replace the old callback-generator functions with the new memoizable callback functions
46+
- Fixed a bug in `Form` to avoid getting errors being reported at the root level via `onChange` when there aren't
3947

4048
## @rjsf/daisyui
4149

4250
- Updated the test mocks to remove `formContext` for the widget mock
43-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
51+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
4452
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
53+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
54+
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplate` to replace the old callback-generator functions with the new memoizable callback functions
4555

4656
## @rjsf/fluentui-rc
4757

48-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
58+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
4959
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
60+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
5061

5162
## @rjsf/mantine
5263

53-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
64+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
5465
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
66+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
5567

5668
## @rjsf/mui
5769

5870
- Updated `BaseInputTemplate` and `SelectWidget` to remove `formContext` from the props
59-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
71+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
6072
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
73+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
6174

6275
## @rjsf/primereact
6376

6477
- Updated `SelectWidget` to remove `formContext` from the props
65-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
78+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
6679
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
80+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
6781

6882
## @rjsf/react-bootstrap
6983

70-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
84+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
7185
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
86+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
7287

7388
## @rjsf/semantic-ui
7489

75-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
90+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
7691
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `RadioWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute
92+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
93+
- Updated `ArrayFieldItemTemplate` to refactor the getting of the `semanticProps` from `ArrayFieldTemplate`, using the new `parentUiSchema` prop to maintain the feature
7794

7895
## @rjsf/shadcn
7996

8097
- Updated the test mocks to remove `formContext` for the widget mock and added `globalFormOptions` in the registry mock
81-
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
98+
- BREAKING CHANGE: Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to rename the old `additionalProperties` interface props to the new ones
8299
- Updated `BaseInputTemplate`, `CheckboxesWidget`, `CheckboxWidget`, `SelectWidget`, and `TextareaWidget` to use `htmlName` for the HTML `name` attribute (Note: `RadioWidget` does not support `htmlName` due to Radix UI RadioGroup limitations)
100+
- BREAKING CHANGE: Updated `ArrayFieldTemplate` to remove the `ArrayFieldItemTemplate` render in favor of simply using `items` due to `ArrayField` changes
83101

84102
## @rjsf/utils
85103

86-
- BREAKING CHANGE: Updated `FieldTemplateProps` and `WrapIfAdditionalTemplateProps` to replace the `onKeyChange()` and `onDropPropertyClick()` callback generator props with the `onKeyRename()`, `onKeyRenameBlur()` and `onRemoveProperty()` callback props
87-
- BREAKING CHANGE: Updated `ObjectFieldTemplateProps` to replace the `onAddClick()` callback generator prop with the `onAddProperty()` callback prop
104+
- BREAKING CHANGE: Updated `FieldTemplateProps` and `WrapIfAdditionalTemplateProps` to replace the `onKeyChange()` and `onDropPropertyClick()` callback-generator props with the `onKeyRename()`, `onKeyRenameBlur()` and `onRemoveProperty()` callback props
105+
- BREAKING CHANGE: Updated `ObjectFieldTemplateProps` to replace the `onAddClick()` callback-generator prop with the `onAddProperty()` callback prop
88106
- Added new hook `useDeepCompareMemo()` and its associated tests
89107
- Added `NameGeneratorFunction` type and two built-in name generators: `bracketNameGenerator` and `dotNotationNameGenerator`
90108
- Updated `GlobalFormOptions` type to include optional `nameGenerator` field
91109
- Updated `toFieldPathId()` function to support name generation via the `nameGenerator` option in `GlobalFormOptions`
92110
- Added `htmlName` field to `WidgetProps` interface to provide the generated HTML `name` attribute to widgets
111+
- BREAKING CHANGE: Renamed `ArrayFieldItemTemplateType` to `ArrayFieldItemTemplateProps` and updated it to change `key: string` to `itemKey: string` to avoid a name collision with React
112+
- BREAKING CHANGE: Updated `ArrayFieldTemplateProps` to change the type of the `items` prop from `ArrayFieldItemTemplateType<T, S, F>[]` to `ReactElement[]`
113+
- BREAKING CHANGE: Updated `ArrayFieldItemButtonsTemplateType` to replace the `onAddIndexClick()`, `onCopyIndexClick()`, `onDropIndexClick()` and `onReorderClick()` callback-generator props with the `onAddItem()`, `onCopyItem()`, `onMoveUpItem()`, `onMoveDownItem()` and `onRemoveItem()` callback props
114+
- BREAKING CHANGE: Updated `ArrayFieldItemTemplateType` to change `key: string` to `itemKey: string` to avoid a name collision with React
115+
- BREAKING CHANGE: Renamed `ArrayFieldItemButtonsTemplateType` to `ArrayFieldItemButtonsTemplateProps` and updated it to replace the `onAddIndexClick()`, `onCopyIndexClick()`, `onDropIndexClick()` and `onReorderClick()` callback-generator props with the `onAddItem()`, `onCopyItem()`, `onMoveUpItem()`, `onMoveDownItem()` and `onRemoveItem()` callback props
93116

94117
## Dev / docs / playground
95118
- Updated the `formTests.tsx` snapshots to add an `anyOf` of all arrays with different item types and removed the disabling of the optional data controls feature for the optional object with oneOfs
@@ -98,9 +121,10 @@ should change the heading of the (upcoming) version to include a major version b
98121
- Updated the `Sample` and `LiveSettings` types to support the `liveSettings` inside of a sample
99122
- Updated the `Playground`'s `onSampleSelected` callback to merge any `liveSettings` in the sample on top of those already used in the playground
100123
- Updated the `customFieldAnyOf` sample to switch `IdSchema` to `FieldPathId`
101-
- Updated the `custom-templates.md` documentation to reflect the `additionalProperties`-based interface props replacement
102-
- Updated the `utility-functions.mf` documenation to add the new `useDeepCompareMemo()` hook
103-
- Updated the `v6.x upgrade guide.md` documentation to add the BREAKING CHANGES to the `FieldTemplateProps`, `ObjectFieldTemplateProps` and `WrapIfAdditionalTemplateProps` interface props changes and the `useDeepCompareMemo()` hook
124+
- Updated the `customArray` sample to refactor out a `ArrayFieldItemButtonsTemplate`
125+
- Updated the `custom-templates.md` documentation to reflect the `additionalProperties`-based interface props replacement and `ArrayField` conversion changes
126+
- Updated the `utility-functions.md` documentation to add the new `useDeepCompareMemo()` hook
127+
- Updated the `v6.x upgrade guide.md` documentation to add the BREAKING CHANGES to the `ArrayFieldTemplateProps`, `ArrayFieldItemTemplateType`, `ArrayFieldItemButtonsTemplateType`, `FieldTemplateProps`, `ObjectFieldTemplateProps` and `WrapIfAdditionalTemplateProps` interface props changes and the `useDeepCompareMemo()` hook
104128
- Added documentation for the `nameGenerator` prop in `form-props.md` and v6.x upgrade guide
105129

106130
# 6.0.0-beta.21

packages/antd/src/templates/ArrayFieldItemTemplate/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Col, Row, Space } from 'antd';
22
import {
3-
ArrayFieldItemTemplateType,
3+
ArrayFieldItemTemplateProps,
44
FormContextType,
55
getUiOptions,
66
getTemplate,
@@ -18,13 +18,13 @@ const BTN_STYLE = {
1818

1919
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
2020
*
21-
* @param props - The `ArrayFieldItemTemplateType` props for the component
21+
* @param props - The `ArrayFieldItemTemplateProps` props for the component
2222
*/
2323
export default function ArrayFieldItemTemplate<
2424
T = any,
2525
S extends StrictRJSFSchema = RJSFSchema,
2626
F extends FormContextType = any,
27-
>(props: ArrayFieldItemTemplateType<T, S, F>) {
27+
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
2828
const { children, buttonsProps, hasToolbar, index, registry, uiSchema } = props;
2929
const uiOptions = getUiOptions<T, S, F>(uiSchema);
3030
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(

packages/antd/src/templates/ArrayFieldTemplate/index.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
getTemplate,
33
getUiOptions,
44
ArrayFieldTemplateProps,
5-
ArrayFieldItemTemplateType,
65
FormContextType,
76
GenericObjectType,
87
RJSFSchema,
@@ -19,7 +18,7 @@ const DESCRIPTION_COL_STYLE = {
1918

2019
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
2120
*
22-
* @param props - The `ArrayFieldItemTemplateType` props for the component
21+
* @param props - The `ArrayFieldTemplateProps` props for the component
2322
*/
2423
export default function ArrayFieldTemplate<
2524
T = any,
@@ -47,11 +46,6 @@ export default function ArrayFieldTemplate<
4746
registry,
4847
uiOptions,
4948
);
50-
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
51-
'ArrayFieldItemTemplate',
52-
registry,
53-
uiOptions,
54-
);
5549
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
5650
'ArrayFieldTitleTemplate',
5751
registry,
@@ -103,9 +97,7 @@ export default function ArrayFieldTemplate<
10397
)}
10498
<Col className='row array-item-list' span={24}>
10599
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
106-
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
107-
<ArrayFieldItemTemplate key={key} {...itemProps} />
108-
))}
100+
{items}
109101
</Col>
110102
{canAdd && (
111103
<Col span={24}>

packages/chakra-ui/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, ButtonGroup, HStack } from '@chakra-ui/react';
22
import {
3-
ArrayFieldItemTemplateType,
3+
ArrayFieldItemTemplateProps,
44
FormContextType,
55
getTemplate,
66
getUiOptions,
@@ -12,7 +12,7 @@ export default function ArrayFieldItemTemplate<
1212
T = any,
1313
S extends StrictRJSFSchema = RJSFSchema,
1414
F extends FormContextType = any,
15-
>(props: ArrayFieldItemTemplateType<T, S, F>) {
15+
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
1616
const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
1717
const uiOptions = getUiOptions<T, S, F>(uiSchema);
1818
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(

packages/chakra-ui/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Box, Grid, GridItem } from '@chakra-ui/react';
22
import {
33
getTemplate,
44
getUiOptions,
5-
ArrayFieldItemTemplateType,
65
ArrayFieldTemplateProps,
76
StrictRJSFSchema,
87
RJSFSchema,
@@ -35,11 +34,6 @@ export default function ArrayFieldTemplate<
3534
registry,
3635
uiOptions,
3736
);
38-
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
39-
'ArrayFieldItemTemplate',
40-
registry,
41-
uiOptions,
42-
);
4337
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
4438
'ArrayFieldTitleTemplate',
4539
registry,
@@ -71,9 +65,7 @@ export default function ArrayFieldTemplate<
7165
<Grid key={`array-item-list-${fieldPathId.$id}`}>
7266
<GridItem>
7367
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
74-
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
75-
<ArrayFieldItemTemplate key={key} {...itemProps} />
76-
))}
68+
{items}
7769
</GridItem>
7870
{canAdd && (
7971
<GridItem justifySelf='flex-end'>

packages/core/src/components/Form.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,11 @@ export default class Form<
862862
customErrors = new ErrorSchemaBuilder<T>();
863863
}
864864
if (isRootPath) {
865-
customErrors.setErrors(_get(newErrorSchema, ERRORS_KEY, ''));
865+
const errors = _get(newErrorSchema, ERRORS_KEY);
866+
if (errors) {
867+
// only set errors when there are some
868+
customErrors.setErrors(errors);
869+
}
866870
} else {
867871
_set(customErrors.ErrorSchema, path, newErrorSchema);
868872
}

0 commit comments

Comments
 (0)