From 78e13798f9e5972d7197afcc660e581e1d6ff660 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Thu, 23 Apr 2020 18:11:56 +0200 Subject: [PATCH] Image widget : fix for lockAspect edit option --- src/widget/edit-widget/edit-widget.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/widget/edit-widget/edit-widget.js b/src/widget/edit-widget/edit-widget.js index 46b92a1..8e79531 100644 --- a/src/widget/edit-widget/edit-widget.js +++ b/src/widget/edit-widget/edit-widget.js @@ -57,8 +57,10 @@ class EditWidgetDialog extends React.Component { const file = this.props.files.find(element => element.id === fileId); // scale width to match aspect + if(file.dimensions){ const aspectRatio = file.dimensions.width / file.dimensions.height; changeObject.width = this.state.temporal.height * aspectRatio; + } return changeObject; } @@ -73,13 +75,13 @@ class EditWidgetDialog extends React.Component { // not a customProperty customProperty = false; } - - if (e.target.id === 'lockAspect') { + + if (parts[1] === 'lockAspect') { //not a customProperty customProperty ? changeObject[parts[0]][parts[1]] = e.target.checked : changeObject[e.target.id] = e.target.checked; // correct image aspect if turned on - if (e.target.checked) { + if (e.target.checked && this.state.temporal.customProperties.file) { changeObject = this.assignAspectRatio(changeObject, this.state.temporal.customProperties.file); } } else if (e.target.id.includes('file')) {