Skip to content

Commit

Permalink
STSMACOM-679: Mark initialValues as immutable in LocationForm (#1256)
Browse files Browse the repository at this point in the history
* STSMACOM-679:  Mark initialValues as immutable in LocationForm
  • Loading branch information
mkuklis authored and zburke committed Jul 25, 2022
1 parent 70acee5 commit f175b39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for stripes-smart-components

## 7.2.1 IN PROGRESS

* Mark `initialValues` as immutable in `<LocationForm>`. Fixes STSMACOM-679.

## [7.2.0](https://github.com/folio-org/stripes-smart-components/tree/v7.2.0) (2022-06-14)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v7.1.0...v7.2.0)

Expand Down
5 changes: 5 additions & 0 deletions lib/LocationLookup/LocationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,9 @@ export default stripesForm({
form: 'locationForm',
navigationCheck: false,
enableReinitialize: true,
// Passing modified initialValues does not re-render the form
// even when enableReinitialize is set to true.
// This seems like a bug in redux-form:
// https://github.com/redux-form/redux-form/issues/2572
immutableProps: ['initialValues'],
})(LocationForm);
3 changes: 2 additions & 1 deletion lib/LocationLookup/LocationModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default class LocationModal extends React.Component {
render() {
const { resources, isTemporaryLocation, ...rest } = this.props;
const { campusId, libraryId, locationId, institutionId } = this.state;
const initialValues = { campusId, libraryId, locationId, institutionId };
const institutions = (resources.institutions || {}).records || [];
const campuses = (resources.campuses || {}).records || [];
const libraries = (resources.libraries || {}).records || [];
Expand All @@ -212,7 +213,7 @@ export default class LocationModal extends React.Component {
dismissible
>
<LocationForm
initialValues={{ campusId, libraryId, locationId, institutionId }}
initialValues={initialValues}
institutions={institutions}
campuses={campuses}
libraries={libraries}
Expand Down

0 comments on commit f175b39

Please sign in to comment.