bughelp wanted
Description
Expected behavior
CloudinaryImage and CloudinaryImages file upload fields should be collapsed when collapse:true.
Actual/Current behavior
Fields are not collapsed.
Steps to reproduce the actual/current behavior
Flyer.add({
date: { type: Types.Date, required: true, initial:true, index: true },
store: { type: Types.Relationship, ref: 'Store', initial: true },
image: { type: Types.CloudinaryImage, required: true, initial:true }
image2: { type: Types.CloudinaryImage, collapse: true, initial:true },
});
Environment
| Software | Version |
|---|---|
| Keystone | 4.0.0-beta.5 |
| Node | 6.11.0 |
Proposed Change
It looks like this issue is caused because the default props.value of these components are being set as an empty object in CloudinaryImage and an empty array in CloudinaryImages. This causes the shouldCollapse helper to return false because it sees the empty object and array as an existing value.
I suggest adding shouldCollapse helper functions to both the broken components that overwrite the default behaviour and instead check whether the fields are empty using the existing hasImage and hasFiles helpers.
☝️ Let me know if this sounds ok and I'll submit a PR!