Skip to content

Commit 23a9aa6

Browse files
STSMACOM-946: Add a default empty object for customFieldsValues so that ViewCustomFieldsRecord can render NoValue when no values are provided. (#1626)
## Description When `customFieldsValues` is undefined, the `ViewCustomFieldsRecord` component crashes, so we always need to pass an empty object. This PR adds a default empty object by default for `customFieldsValues`, so we no longer need to pass an empty object in all places where `ViewCustomFieldsRecord` is used. ## Issues https://folio-org.atlassian.net/browse/STSMACOM-946
1 parent 3d54b01 commit 23a9aa6

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* Dependency correction: remember bumping `react-intl` to v7? Yeah? Actually do that. Refs STSMACOM-941.
3636
* `<DateRangeFilter>` - set only the start date field as a focus ref. Fixes STSMACOM-944.
3737
* Add a limit of 100 for tenant rules in the `PasswordValidationField`. Fixes STSMACOM-942.
38+
* Add a default empty object for `customFieldsValues` so that `ViewCustomFieldsRecord` can render `NoValue` when no values are provided. Refs STSMACOM-946.
3839

3940
## [10.0.0](https://github.com/folio-org/stripes-smart-components/tree/v10.0.0) (2025-02-24)
4041
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.2.0...v10.0.0)

lib/CustomFields/pages/ViewCustomFieldsRecord/ViewCustomFieldsRecord.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const propTypes = {
4444
columnCount: PropTypes.number,
4545
configNamePrefix: PropTypes.string,
4646
customFieldsLabel: PropTypes.node,
47-
customFieldsValues: PropTypes.object.isRequired,
47+
customFieldsValues: PropTypes.object,
4848
entityType: PropTypes.string.isRequired,
4949
expanded: PropTypes.bool,
5050
isSectionTitleEnabled: PropTypes.bool,
@@ -61,7 +61,7 @@ const ViewCustomFieldsRecord = ({
6161
expanded,
6262
backendModuleName,
6363
entityType,
64-
customFieldsValues,
64+
customFieldsValues = {},
6565
columnCount = 4,
6666
customFieldsLabel = <FormattedMessage id="stripes-smart-components.customFields" />,
6767
noCustomFieldsFoundLabel = <FormattedMessage id="stripes-smart-components.customFields.noCustomFieldsFound" />,

lib/CustomFields/pages/ViewCustomFieldsRecord/tests/ViewCustomFieldsRecord-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,12 @@ describe('ViewCustomFieldsRecord', () => {
140140

141141
it('should display all custom fields without accordion', () => CFContainer().has({ fieldCount: 7 }));
142142
});
143+
144+
describe('when customFieldsValues is not provided', () => {
145+
beforeEach(async () => {
146+
await renderComponent({ customFieldsValues: undefined });
147+
});
148+
149+
it('should display NoValue for all fields', () => viewCustomFields.has({ fieldCount: 7 }));
150+
});
143151
});

lib/CustomFields/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Name | type | description | required | default
123123
`columnCount` | number | grid display in the same menner as other accordions in current page | false | 4
124124
`configNamePrefix` | string | used to extend `configName` to use different storage for the section title when making requests to `mod-configuration` | false
125125
`customFieldsLabel` | node | default accordion label | false | `<FormattedMessage id="stripes-smart-components.customFields" />`
126-
`customFieldsValues` | object | values for the custom fields | true |
126+
`customFieldsValues` | object | values for the custom fields | false | {}
127127
`entityType` | string | used to filter custom files by particular entity type | true |
128128
`expanded` | boolean | accordion open or closed | true |
129129
`isSectionTitleEnabled` | boolean | enables/disables fetching and displaying the section title | false | true

0 commit comments

Comments
 (0)