0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Fixed product card throwing "Cannot read properties of undefined (reading 'url')" errors

closes https://github.com/TryGhost/Team/issues/2295

Problem:
- `<GhUploader>` is not yet converted to an Octane component so it's arguments are not read-only
- when a file is selected it sets it's `files` property which in turn updates the tracked `files` property that was passed in, and then again updates it to an empty file list when the input field is cleared
- that tracked property was never cleared once the product image was uploaded resulting in a "re-upload" attempt with an empty file list every time the product card was put back into edit mode

Fix:
- added a guard in `<GhUploader>` so it doesn't try to upload an empty file list if one is passed in as an attribute
- added a reset of the tracked `files` property in the product card once the image upload is complete
This commit is contained in:
Kevin Ansfield 2022-11-22 13:13:42 +00:00
parent 955605572e
commit f25cc00236
2 changed files with 5 additions and 2 deletions

View file

@ -113,8 +113,9 @@ export default Component.extend({
}
// if we have new files, validate and start an upload
let files = this.files;
this._setFiles(files);
if (this.files?.length) {
this._setFiles(this.files);
}
},
actions: {

View file

@ -267,6 +267,8 @@ export default class KoenigCardProductComponent extends Component {
this._productImageWidth = null;
this._productImageHeight = null;
});
this.files = null;
}
/**