Skip to content

Commit

Permalink
Fix #3608 by removing ternary and ensuring AntD FieldTemplate wraps r…
Browse files Browse the repository at this point in the history
…oot in `Form.Item` (#3621)

Co-authored-by: Heath C <[email protected]>
  • Loading branch information
nickgros and heath-freenome authored Apr 22, 2023
1 parent 436493b commit 24cd2bc
Show file tree
Hide file tree
Showing 5 changed files with 12,586 additions and 10,491 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ should change the heading of the (upcoming) version to include a major version b
-->

# 5.6.3

## @rjsf/antd

- Fix [#3608](https://github.com/rjsf-team/react-jsonschema-form/issues/3608) by ensuring the root field is always wrapped in Form.Item

# 5.6.2

## Dev / docs / playground
Expand Down
34 changes: 15 additions & 19 deletions packages/antd/src/templates/FieldTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,21 @@ export default function FieldTemplate<
uiSchema={uiSchema}
registry={registry}
>
{id === 'root' ? (
children
) : (
<Form.Item
colon={colon}
hasFeedback={schema.type !== 'array' && schema.type !== 'object'}
help={(!!rawHelp && help) || (rawErrors?.length ? errors : undefined)}
htmlFor={id}
label={displayLabel && label}
labelCol={labelCol}
required={required}
style={wrapperStyle}
validateStatus={rawErrors?.length ? 'error' : undefined}
wrapperCol={wrapperCol}
{...descriptionProps}
>
{children}
</Form.Item>
)}
<Form.Item
colon={colon}
hasFeedback={schema.type !== 'array' && schema.type !== 'object'}
help={(!!rawHelp && help) || (rawErrors?.length ? errors : undefined)}
htmlFor={id}
label={displayLabel && label}
labelCol={labelCol}
required={required}
style={wrapperStyle}
validateStatus={rawErrors?.length ? 'error' : undefined}
wrapperCol={wrapperCol}
{...descriptionProps}
>
{children}
</Form.Item>
</WrapIfAdditionalTemplate>
);
}
Loading

0 comments on commit 24cd2bc

Please sign in to comment.