Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit ed5d6b3

Browse files
committed
fix: combine crops coming from the property editor with the server so that we ignore any invalid (old) crops
it has the added benefit of allowing us to find the `label` of a crop
1 parent dc85294 commit ed5d6b3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/packages/media/media/modals/image-cropper-editor/image-cropper-editor-modal.element.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ export class UmbImageCropperEditorModalElement extends UmbModalBaseElement<
7979
const item = data?.[0];
8080

8181
if (!item?.url) return;
82+
83+
/**
84+
* Combine the crops from the property editor with the stored crops and ignore any invalid crops
85+
* (e.g. crops that have been removed from the property editor)
86+
* @remark If a crop is removed from the property editor, it will be ignored and not saved
87+
*/
88+
const crops: Array<UmbCropModel> = this._crops.map((crop) => {
89+
const existingCrop = this.value.crops?.find((c) => c.alias === crop.alias);
90+
return existingCrop ? { ...crop, ...existingCrop } : crop;
91+
});
92+
8293
const value: UmbImageCropperPropertyEditorValue = {
8394
...this.value,
8495
src: item.url,
85-
crops: this.value.crops?.length ? this.value.crops : this._crops,
96+
crops,
8697
focalPoint: this.value.focalPoint ?? { left: 0.5, top: 0.5 },
8798
};
8899
this._imageCropperValue = value;

0 commit comments

Comments
 (0)