mirror of
https://github.com/penpot/penpot.git
synced 2026-05-11 19:13:49 +00:00
* 📎 Add test that surfaces the bug described in #14070 The bug: alt-drag-duplicating a variant master into the variant container auto-creates a new variant component cloned from the source via duplicate-component, which preserves :touched on every cloned shape. The resulting copy's children inherit those :geometry-group touched flags through add-touched-from-ref-chain on switch. variants-switch -> component-swap (keep-touched? true) -> generate-keep-touched then runs update-attrs-on-switch for each touched child. The new shape's :y is correctly skipped by the per-attr "different masters" guard, but :selrect/:points fall through to a width/height-based safety check that uses exact equality. In practice, the alt-drag modifier path leaves a sub-pixel drift in :width on the copy, so equal-geometry? returns false, the safety check is bypassed, and the :else branch copies the source variant's :selrect verbatim onto the freshly instantiated target shape. The shape ends up with :y from the target master but :selrect.y from the source — the renderer reads :selrect, so the child appears at the source position inside a parent that has resized to the target's dimensions: the visible "button cut off" symptom. The new test sets up a variant container whose children are themselves component copies (matching production: variant masters' children carry :touched), introduces the same kind of width drift on the copy that the alt-drag path produces, and runs the swap directly via the existing test harness. It asserts (a) :y matches the target, (b) :selrect.y matches the target, and (c) :y and :selrect.y agree. With the current code (a) passes and (b)/(c) fail — capturing both the wrong value and the internal inconsistency that causes the visible regression. * 🐛 Fix #14070 by no longer comparing floats for exact equality in equal-geometry?