Skip to content

Commit

Permalink
fix: 3253 By adding schema to ArrayFieldTemplateItemType type (#3298)
Browse files Browse the repository at this point in the history
fix: #3253 by adding `schema` prop `ArrayFieldTemplateItemType` type to make it consistent with all the rest of the template types
- In `@rjsf/utils`, updated `types.ts` to add `schema` to the `ArrayFieldTemplateItemType` type
- In `@rjsf/core`, updated the `ArrayField` template to pass the `schema` to the props that are provided to the instance of the `ArrayFieldItemTemplate`
- Updated `custom-templates.md` to add the `schema` to the documentation for `ArrayFieldItemTemplate`
- Updated the `CHANGELOG.md` accordingly
  • Loading branch information
heath-freenome committed Dec 19, 2022
1 parent b7296e1 commit 6f4e419
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,17 @@ it according to semantic versioning. For example, if your PR adds a breaking cha
should change the heading of the (upcoming) version to include a major version bump.
-->
# 5.0.0-beta-15

# @rjsf/core
- Pass the `schema` along to the `ArrayFieldItemTemplate` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253)

# @rjsf/utils
- Update the `ArrayFieldItemTemplate` to add `schema` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253)

## Dev / docs / playground
- Fixed the documentation for `ArrayFieldItemTemplate` as part of the fix for [#3253](https://github.com/rjsf-team/react-jsonschema-form/issues/3253)

# 5.0.0-beta.14

## @rjsf/antd
Expand Down
1 change: 1 addition & 0 deletions docs/advanced-customization/custom-templates.md
Expand Up @@ -222,6 +222,7 @@ The following props are passed to each `ArrayFieldItemTemplate`:
- `onDropIndexClick: (index) => (event?) => void`: Returns a function that removes the item at `index`.
- `onReorderClick: (index, newIndex) => (event?) => void`: Returns a function that swaps the items at `index` with `newIndex`.
- `readonly`: A boolean value stating if the array item is read-only.
- `schema`: The schema object for this array item.
- `uiSchema`: The uiSchema object for this array item.
- `registry`: The `registry` object.

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/components/fields/ArrayField.tsx
Expand Up @@ -862,6 +862,7 @@ class ArrayField<
onReorderClick: this.onReorderClick,
readonly,
registry,
schema: itemSchema,
uiSchema: itemUiSchema,
};
}
Expand Down
4 changes: 3 additions & 1 deletion packages/utils/src/types.ts
Expand Up @@ -520,7 +520,9 @@ export type ArrayFieldTemplateItemType<
readonly: boolean;
/** A stable, unique key for the array item */
key: string;
/** The uiSchema object for this field */
/** The schema object for this array item */
schema: S;
/** The uiSchema object for this array item */
uiSchema?: UiSchema<T, S, F>;
/** The `registry` object */
registry: Registry<T, S, F>;
Expand Down

0 comments on commit 6f4e419

Please sign in to comment.