utopia
utopia copied to clipboard
Pin toggling is not undo/redo safe.
Describe the bug
If the left and right properties are set on an element and the width pin toggle is triggered, the first time this may work correctly but if the user triggers an undo and does it again then the editor may remove both the left and right properties.
To Reproduce
- Create a regular frame child element with
leftandrightstyle properties. - Trigger the
widthpin toggle. - Undo the toggle with the undo shortcut.
- Trigger the
widthpin toggle.
Result: Now the element only has the width horizontal style property.
Expected behaviour The element should have the same properties that it did before the undo action.
Note
It looks to be something to do with these lines in usePinToggling:
const [lastHorizontalProp, setLastHorizontalProp] = React.useState<LayoutPinnedProp | null>(null)
const [lastVerticalProp, setLastVerticalProp] = React.useState<LayoutPinnedProp | null>(null)
As lastHorizontalProp being set to width after the first change, but doesn't get reset as a result of the undo.