Skip to content

Commit

Permalink
workingElement
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrmendy committed Oct 25, 2024
1 parent 629c2cb commit 5832b1f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions editor/src/components/canvas/commands/adjust-css-length-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export const runAdjustCssLengthProperties = (
if (isJSXElement(element)) {
return command.properties.reduce((workingElement, property) => {
// Get the current value of the property...
const currentValue = getModifiableJSXAttributeAtPath(element.props, property.property)
const currentValue = getModifiableJSXAttributeAtPath(
workingElement.props,
property.property,
)
// ...If the value is not writeable then escape out.
if (isLeft(currentValue)) {
commandDescriptions.push(
Expand Down Expand Up @@ -168,7 +171,7 @@ export const runAdjustCssLengthProperties = (
if (isRight(parsePxResult)) {
return handleUpdateResult(
updatePixelValueByPixel(
element.props,
workingElement.props,
command.target,
property.property,
parsePxResult.value,
Expand All @@ -183,7 +186,7 @@ export const runAdjustCssLengthProperties = (
if (isRight(parsePercentResult)) {
return handleUpdateResult(
updatePercentageValueByPixel(
element.props,
workingElement.props,
command.target,
property.property,
property.parentDimensionPx,
Expand All @@ -196,7 +199,12 @@ export const runAdjustCssLengthProperties = (
// Otherwise if it is permitted to create it if it doesn't exist, then do so.
if (property.createIfNonExistant === 'create-if-not-existing') {
return handleUpdateResult(
setPixelValue(element.props, command.target, property.property, property.valuePx),
setPixelValue(
workingElement.props,
command.target,
property.property,
property.valuePx,
),
)
}

Expand Down Expand Up @@ -416,6 +424,10 @@ export function deleteConflictingPropsForWidthHeight(
): EditorState {
return propertyPaths.reduce((editor, propertyPath) => {
const propertiesToDelete = getConflictingPropertiesToDelete(parentFlexDirection, propertyPath)
if (propertiesToDelete.length === 0) {
return editor
}

return runStyleUpdateForStrategy(
interactionLifecycle,
editor,
Expand Down

0 comments on commit 5832b1f

Please sign in to comment.