Skip to content

Commit 6435b33

Browse files
Fix 3296 by adjusting buttons location for the array field toolbar (rjsf-team#4859)
* Fix 3296 by adjusting buttons location for the array field toolbar Fixed rjsf-team#3296 by updating `ArrayFieldItemTemplateProps` to add `displayLabel` and `hasDescription` and using them in the themes to adjust buttons location - In `@rjsf/utils`, updated `ArrayFieldItemTemplateProps` to add `displayLabel` and `hasDescription` flags - In `@rjsf/core`, updated `ArrayField` to compute and pass `displayLabel` and `hasDescription` flags - Updated `ArrayFieldItemTemplate` to use `displayLabel` and `hasDescription` to adjust buttons location - Also fixed bug where `StringField` was not using the `title` passed to it as found in `mantine` theme - In `@rjsf/antd`, updated `ArrayFieldItemTemplate` and `ArrayFieldTemplate` to adjust sizes and buttons location using `displayLabel` and `hasDescription` - In `@rjsf/chakra-ui`, updated snapshots due to `StringField` fix - In `@rjsf/daisyui`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription` - Also updated `WrapIfAdditionalTemplate` and `BaseInputTemplate` to make the inputs full width - Also updated `FieldTemplate` to render the `description` which was missing in the theme - In `@rjsf/fluentui-rc`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` - Also updated `WrapIfAdditionalTemplate` to add `flexGrow` to allow the array item fields to grow properly for non-container elements - In `@rjsf/mantine`, updated `utils.ts` to add `label` to the cleanup fields to filter it from the `uiOptions` - Also updated `BaseInputTemplate` to display `description` which was missing in the theme - Also updated `ArrayFieldTitleTemplate` to support the `optionalData` - In `@rjsf/mui`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription` - In `@rjsf/primereact`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` - In `@rjsf/react-bootstrap`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription` - Also, updated `ArrayFieldTemplate` to improve it's responsiveness in relation to the `ArrayFieldItemTemplate` changes - In `@rjsf/semantic-ui`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription` - In `@rjsf/shadcn`, updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription` - Also updated `ArrayFieldTemplate` to add `justify-end` to the `AddButton` rendering - Updated all snapshots due to above changes - Updated `uiSchema.md` in the docs to document the new `enableMarkdownInHelp` flag from previous PR - Updated the `CHANGELOG.md` accordingly * Update packages/mantine/src/templates/BaseInputTemplate.tsx * - Updated snapshots * - Restored space in `classNames` that was accidentally removed
1 parent 47c8513 commit 6435b33

File tree

60 files changed

+3499
-2290
lines changed

Some content is hidden

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

60 files changed

+3499
-2290
lines changed

CHANGELOG.md

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

2222
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
23+
- 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)
2324

24-
## @rjsf/antd
25-
26-
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
27-
28-
## @rjsf/antd
25+
## @rjsf/chakra-ui
2926

3027
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
3128

32-
## @rjsf/mui
29+
## @rjsf/core
3330

34-
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
31+
- Added new `RichHelp` component for use in all the themes for help rendering, fixing [#4601](https://github.com/rjsf-team/react-jsonschema-form/issues/4601)
32+
- Updated `ArrayField` to compute and pass `displayLabel` and `hasDescription` to the rendered `ArrayFieldItemTemplate` to support fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
33+
- Updated `StringField` to extract the `title` from the props and pass it down to the widget if provided
34+
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
35+
- Updated `AddButton` to improve it's responsiveness in relation to the `ArrayFieldItemTemplate` changes
3536

36-
## @rjsf/shadcn
37+
## @rjsf/daisyui
3738

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

40-
## @rjsf/primereact
44+
## @rjsf/fluentui-rc
4145

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

44-
## @rjsf/react-bootstrap
50+
## @rjsf/mantine
4551

4652
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
53+
- Updated `utils.ts` to add `label` to the cleanup fields to filter it from the `uiOptions`
54+
- Updated `BaseInputTemplate` to display `description` which was missing in the theme
55+
- Updated `ArrayFieldTitleTemplate` to support the `optionalData`
4756

48-
## @rjsf/semantic-ui
57+
## @rjsf/mui
4958

5059
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
60+
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
5161

52-
## @rjsf/daisyui
62+
## @rjsf/primereact
5363

5464
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
65+
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
5566

56-
## @rjsf/fluentui-rc
67+
## @rjsf/react-bootstrap
5768

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

60-
## @rjsf/chakra-ui
73+
## @rjsf/semantic-ui
6174

6275
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
76+
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
6377

64-
## @rjsf/mantine
78+
## @rjsf/shadcn
6579

6680
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
81+
- Updated `ArrayFieldItemTemplate` to adjust buttons location using `displayLabel` and `hasDescription`, fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
82+
- Updated `ArrayFieldTemplate` to add `justify-end` to the `AddButton` rendering
6783

6884
## @rjsf/utils
6985

70-
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
86+
- Added new `enableMarkdownInHelp` to the `GlobalUISchemaOptions` type, fixing [#4601](https://github.com/rjsf-team/react-jsonschema-form/issues/4601)
87+
- Added new `displayLabel` and `hasDescription` flags in the `ArrayFieldItemTemplateProps` to support fixing [#3296](https://github.com/rjsf-team/react-jsonschema-form/issues/3296)
88+
- Updated the three hooks to add `use client` directive to support NextJS builds
89+
90+
## Dev / docs / playground
7191

92+
- Updated `uiSchema.md` in the docs to document the new `enableMarkdownInHelp` flag
7293

7394
# 6.0.2
7495

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010

1111
const BTN_GRP_STYLE = {
1212
width: '100%',
13+
justifyContent: 'flex-end',
1314
};
1415

1516
const BTN_STYLE = {
@@ -25,21 +26,21 @@ export default function ArrayFieldItemTemplate<
2526
S extends StrictRJSFSchema = RJSFSchema,
2627
F extends FormContextType = any,
2728
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
28-
const { children, buttonsProps, hasToolbar, index, registry, uiSchema } = props;
29+
const { children, buttonsProps, displayLabel, hasDescription, hasToolbar, index, registry, uiSchema } = props;
2930
const uiOptions = getUiOptions<T, S, F>(uiSchema);
3031
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
3132
'ArrayFieldItemButtonsTemplate',
3233
registry,
3334
uiOptions,
3435
);
35-
const { rowGutter = 24, toolbarAlign = 'top' } = registry.formContext;
36+
const { rowGutter = 24, toolbarAlign = displayLabel ? 'middle' : 'top' } = registry.formContext;
37+
const margin = hasDescription ? -8 : 16;
3638

3739
return (
3840
<Row align={toolbarAlign} key={`rjsf-array-item-${index}`} gutter={rowGutter}>
3941
<Col flex='1'>{children}</Col>
40-
4142
{hasToolbar && (
42-
<Col flex='192px'>
43+
<Col flex='120px' style={{ marginTop: displayLabel ? `${margin}px` : undefined }}>
4344
<Space.Compact style={BTN_GRP_STYLE}>
4445
<ArrayFieldItemButtonsTemplate {...buttonsProps} style={BTN_STYLE} />
4546
</Space.Compact>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function ArrayFieldTemplate<
8282
{canAdd && (
8383
<Col span={24}>
8484
<Row gutter={rowGutter} justify='end'>
85-
<Col flex='192px'>
85+
<Col flex='120px'>
8686
<AddButton
8787
id={buttonId(fieldPathId, 'add')}
8888
className='rjsf-array-item-add'

0 commit comments

Comments
 (0)