Skip to content

Commit ef478cf

Browse files
authored
Merge pull request #17970 from umbraco/v15/bugfix/save-image-when-changing-focal-point
Fixes bug change focal point of Image Cropper can not save image
2 parents 72cae41 + bb8ef2c commit ef478cf

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/image-cropper-focus-setter.element.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ export class UmbImageCropperFocusSetterElement extends UmbLitElement {
122122

123123
const focalPoint = { left, top } as UmbFocalPointModel;
124124

125-
console.log('setFocalPoint', focalPoint);
126-
127125
this.dispatchEvent(new UmbFocalPointChangeEvent(focalPoint));
128126
}
129127

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/input-image-cropper.element.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ import './image-cropper-focus-setter.element.js';
1313
import './image-cropper-preview.element.js';
1414
import './image-cropper-field.element.js';
1515

16+
const DefaultFocalPoint = { left: 0.5, top: 0.5 };
17+
const DefaultValue = {
18+
temporaryFileId: null,
19+
src: '',
20+
crops: [],
21+
focalPoint: DefaultFocalPoint,
22+
};
23+
1624
@customElement('umb-input-image-cropper')
1725
export class UmbInputImageCropperElement extends UmbLitElement {
1826
@query('#dropzone')
1927
private _dropzone?: UUIFileDropzoneElement;
2028

2129
@property({ attribute: false })
22-
value: UmbImageCropperPropertyEditorValue = {
23-
temporaryFileId: null,
24-
src: '',
25-
crops: [],
26-
focalPoint: { left: 0.5, top: 0.5 },
27-
};
30+
value: UmbImageCropperPropertyEditorValue = DefaultValue;
2831

2932
@property({ attribute: false })
3033
crops: UmbImageCropperPropertyEditorValue['crops'] = [];
@@ -68,7 +71,7 @@ export class UmbInputImageCropperElement extends UmbLitElement {
6871
}
6972

7073
#onRemove = () => {
71-
this.value = assignToFrozenObject(this.value, { src: '', temporaryFileId: null });
74+
this.value = assignToFrozenObject(this.value, DefaultValue);
7275
if (this.fileUnique) {
7376
this.#manager?.removeOne(this.fileUnique);
7477
}
@@ -116,11 +119,15 @@ export class UmbInputImageCropperElement extends UmbLitElement {
116119
const value = (e.target as UmbInputImageCropperFieldElement).value;
117120

118121
if (!value) {
119-
this.value = { src: '', crops: [], focalPoint: { left: 0.5, top: 0.5 }, temporaryFileId: null };
122+
this.value = DefaultValue;
120123
this.dispatchEvent(new UmbChangeEvent());
121124
return;
122125
}
123126

127+
if (this.value && this.value.temporaryFileId) {
128+
value.temporaryFileId = this.value.temporaryFileId;
129+
}
130+
124131
this.value = value;
125132
this.dispatchEvent(new UmbChangeEvent());
126133
}

0 commit comments

Comments
 (0)