Skip to content

Commit 36908df

Browse files
Fix 4772 by always generating the outer grid regardless of the number of properties (#4775)
Fixed #4772 by always genering the outer grid - Updated `chakra-ui`'s `ObjectFieldTemplate` to render the outer `Grid` regardless of the number of properties - Updated the `CHANGELOG.md` accordingly
1 parent ca2ddc2 commit 36908df

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ should change the heading of the (upcoming) version to include a major version b
1717
-->
1818
# 6.0.0-beta.17
1919

20+
## @rjsf/chakra-ui
21+
22+
- Updated `ObjectFieldTemplate` to always generate the "Add" button when `canExpand()` is true, fixing [#4772](https://github.com/rjsf-team/react-jsonschema-form/issues/4772)
23+
2024
## @rjsf/core
2125

2226
- Updated `ObjectField` to remove the `name` from the path passed to `onChange()` callback in `handleAddClick()` and `onDropPropertyClick()`, fixing [#4763](https://github.com/rjsf-team/react-jsonschema-form/issues/4763)

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,27 @@ export default function ObjectFieldTemplate<
6464
registry={registry}
6565
/>
6666
)}
67-
{properties.length > 0 && (
68-
<Grid gap={description ? 2 : 6} mb={4}>
69-
{properties.map((element, index) =>
70-
element.hidden ? (
71-
element.content
72-
) : (
73-
<GridItem key={`${idSchema.$id}-${element.name}-${index}`}>{element.content}</GridItem>
74-
),
75-
)}
76-
{canExpand<T, S, F>(schema, uiSchema, formData) && (
77-
<GridItem justifySelf='flex-end'>
78-
<AddButton
79-
id={buttonId<T>(idSchema, 'add')}
80-
className='rjsf-object-property-expand'
81-
onClick={onAddClick(schema)}
82-
disabled={disabled || readonly}
83-
uiSchema={uiSchema}
84-
registry={registry}
85-
/>
86-
</GridItem>
87-
)}
88-
</Grid>
89-
)}
67+
<Grid gap={description ? 2 : 6} mb={4}>
68+
{properties.map((element, index) =>
69+
element.hidden ? (
70+
element.content
71+
) : (
72+
<GridItem key={`${idSchema.$id}-${element.name}-${index}`}>{element.content}</GridItem>
73+
),
74+
)}
75+
{canExpand<T, S, F>(schema, uiSchema, formData) && (
76+
<GridItem justifySelf='flex-end'>
77+
<AddButton
78+
id={buttonId<T>(idSchema, 'add')}
79+
className='rjsf-object-property-expand'
80+
onClick={onAddClick(schema)}
81+
disabled={disabled || readonly}
82+
uiSchema={uiSchema}
83+
registry={registry}
84+
/>
85+
</GridItem>
86+
)}
87+
</Grid>
9088
</>
9189
);
9290
}

0 commit comments

Comments
 (0)