Skip to content

Commit

Permalink
Always update schema data in redux as the underlying data may have ch…
Browse files Browse the repository at this point in the history
…anged regardless of its ID set matching

Fixes silverstripe#960
  • Loading branch information
stevie-mayhew committed Aug 12, 2019
1 parent eb06d6c commit ef67715
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions client/src/components/UploadField/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,8 @@ class UploadField extends Component {
}

componentDidMount() {
// Copy form schema data into redux and then ignore it
const { id, data, actions, value, files } = this.props;

// If the data within the "files" prop already matches the value then we don't need to copy
// schema data into redux
if (
value && value.Files && files && value.Files.length === files.length
&& files.filter(file => !value.Files.includes(file.id)).length === 0
) {
return;
}

// Copy form schema data into redux
const { id, data, actions } = this.props;
actions.uploadField.setFiles(id, data.files);
}

Expand Down

0 comments on commit ef67715

Please sign in to comment.