Skip to content

Commit ad84ef7

Browse files
Fix Additional Properties buttons location (rjsf-team#4862)
Co-authored-by: Nick Grosenbacher <[email protected]>
1 parent 6435b33 commit ad84ef7

File tree

51 files changed

+17990
-4688
lines changed

Some content is hidden

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

51 files changed

+17990
-4688
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ should change the heading of the (upcoming) version to include a major version b
2121

2222
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
2323
- Updated `ArrayFieldItemTemplate` and `ArrayFieldTemplate` to adjust sizes and buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
24+
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel`
2425

2526
## @rjsf/chakra-ui
2627

2728
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
29+
- Updated `FieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
2830

2931
## @rjsf/core
3032

@@ -33,63 +35,75 @@ should change the heading of the (upcoming) version to include a major version b
3335
- Updated `StringField` to extract the `title` from the props and pass it down to the widget if provided
3436
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
3537
- Updated `AddButton` to improve it's responsiveness in relation to the `ArrayFieldItemTemplate` changes
38+
- Updated `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
3639

3740
## @rjsf/daisyui
3841

3942
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
4043
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
4144
- Updated `WrapIfAdditionalTemplate` to add `flexGrow` and `BaseInputTemplate` to add `w-full` to allow the array item fields to grow properly
4245
- Updated `FieldTemplate` to render the `description` which was missing in the theme
46+
- Updated `FieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
4347

4448
## @rjsf/fluentui-rc
4549

4650
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
4751
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
4852
- Updated `WrapIfAdditionalTemplate` to add `flexGrow` to allow the array item fields to grow properly for non-container elements
53+
- Updated `FieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
4954

5055
## @rjsf/mantine
5156

5257
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
5358
- Updated `utils.ts` to add `label` to the cleanup fields to filter it from the `uiOptions`
5459
- Updated `BaseInputTemplate` to display `description` which was missing in the theme
5560
- Updated `ArrayFieldTitleTemplate` to support the `optionalData`
61+
- Updated `FieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
5662

5763
## @rjsf/mui
5864

5965
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
6066
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
67+
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel`
6168

6269
## @rjsf/primereact
6370

6471
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
6572
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
73+
- Updated `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
6674

6775
## @rjsf/react-bootstrap
6876

6977
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
7078
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
7179
- Updated `ArrayFieldTemplate` to improve it's responsiveness in relation to the `ArrayFieldItemTemplate` changes
80+
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
7281

7382
## @rjsf/semantic-ui
7483

7584
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
7685
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
86+
- Updated `FieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
7787

7888
## @rjsf/shadcn
7989

8090
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
8191
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
8292
- Updated `ArrayFieldTemplate` to add `justify-end` to the `AddButton` rendering
93+
- Updated `FieldTemplate`, `ObjectFieldTemplate` and `WrapIfAdditionalTemplate` to adjust the sizes and buttons location using `displayLabel` and `rawDescription`
8394

8495
## @rjsf/utils
8596

8697
- Added new `enableMarkdownInHelp` to the `GlobalUISchemaOptions` type, fixing [#4601](https://github.com/rjsf-team/react-jsonschema-form/issues/4601)
8798
- Added new `displayLabel` and `hasDescription` flags in the `ArrayFieldItemTemplateProps` to support fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
8899
- Updated the three hooks to add `use client` directive to support NextJS builds
100+
- Updated `WrapIfAdditionalTemplateProps` to also pick the `displayLabel` and `rawDescription` props from `FieldProps` for use in adjusting the Additional Properties buttons location
101+
- Fixed bug in `getDisplayLabel()` to return false ALWAYS, when the `ui:options` is set to false AND to return true for `array` and `object` types when they were added via additionalProperties
89102

90103
## Dev / docs / playground
91104

92105
- Updated `uiSchema.md` in the docs to document the new `enableMarkdownInHelp` flag
106+
- Updated `objectTests.tsx` to increase the variations of the additionalProperties tests to include labels off, descriptions and object and array types
93107

94108
# 6.0.2
95109

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,16 @@ export default function FieldTemplate<
2424
>(props: FieldTemplateProps<T, S, F>) {
2525
const {
2626
children,
27-
classNames,
28-
style,
2927
description,
30-
disabled,
3128
displayLabel,
3229
errors,
3330
help,
3431
rawHelp,
3532
hidden,
3633
id,
3734
label,
38-
onKeyRename,
39-
onKeyRenameBlur,
40-
onRemoveProperty,
4135
rawErrors,
4236
rawDescription,
43-
readonly,
4437
registry,
4538
required,
4639
schema,
@@ -82,21 +75,7 @@ export default function FieldTemplate<
8275
}
8376
const isCheckbox = uiOptions.widget === 'checkbox';
8477
return (
85-
<WrapIfAdditionalTemplate
86-
classNames={classNames}
87-
style={style}
88-
disabled={disabled}
89-
id={id}
90-
label={label}
91-
onKeyRename={onKeyRename}
92-
onKeyRenameBlur={onKeyRenameBlur}
93-
onRemoveProperty={onRemoveProperty}
94-
readonly={readonly}
95-
required={required}
96-
schema={schema}
97-
uiSchema={uiSchema}
98-
registry={registry}
99-
>
78+
<WrapIfAdditionalTemplate {...props}>
10079
<Form.Item
10180
colon={colon}
10281
hasFeedback={schema.type !== 'array' && schema.type !== 'object'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export default function ObjectFieldTemplate<
133133
{canExpand(schema, uiSchema, formData) && (
134134
<Col span={24}>
135135
<Row gutter={rowGutter} justify='end'>
136-
<Col flex='192px'>
136+
<Col flex='120px'>
137137
<AddButton
138138
id={buttonId(fieldPathId, 'add')}
139139
className='rjsf-object-property-expand'

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function WrapIfAdditionalTemplate<
3232
classNames,
3333
style,
3434
disabled,
35+
displayLabel,
3536
id,
3637
label,
3738
onRemoveProperty,
@@ -82,7 +83,7 @@ export default function WrapIfAdditionalTemplate<
8283
className='form-group'
8384
hasFeedback
8485
htmlFor={`${id}-key`}
85-
label={keyLabel}
86+
label={displayLabel ? keyLabel : undefined}
8687
labelCol={labelCol}
8788
required={required}
8889
style={wrapperStyle}
@@ -104,7 +105,7 @@ export default function WrapIfAdditionalTemplate<
104105
<Col className='form-additional' flex='1'>
105106
{children}
106107
</Col>
107-
<Col flex='192px'>
108+
<Col flex='120px' style={{ marginTop: displayLabel ? '40px' : undefined }}>
108109
<RemoveButton
109110
id={buttonId(id, 'remove')}
110111
className='rjsf-object-property-remove'

packages/antd/test/__snapshots__/Array.test.tsx.snap

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9344,17 +9344,6 @@ exports[`with title and description with global label off checkboxes 1`] = `
93449344
<div
93459345
class="ant-row ant-form-item-row css-dev-only-do-not-override-ac2jek"
93469346
>
9347-
<div
9348-
class="ant-col ant-col-24 ant-form-item-label css-dev-only-do-not-override-ac2jek"
9349-
>
9350-
<label
9351-
class=""
9352-
for="root"
9353-
title="Test field"
9354-
>
9355-
Test field
9356-
</label>
9357-
</div>
93589347
<div
93599348
class="ant-col ant-col-24 ant-form-item-control css-dev-only-do-not-override-ac2jek"
93609349
>

0 commit comments

Comments
 (0)