utopia icon indicating copy to clipboard operation
utopia copied to clipboard

Pin toggling is not undo/redo safe.

Open seanparsons opened this issue 2 years ago • 0 comments

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

  1. Create a regular frame child element with left and right style properties.
  2. Trigger the width pin toggle.
  3. Undo the toggle with the undo shortcut.
  4. Trigger the width pin 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.

seanparsons avatar Oct 30 '23 16:10 seanparsons