mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Sync a swap back inside a copy of a deleted component
Swapping or switching a nested copy back to its slot's own component makes it a plain copy of its position, and the swap syncs it through the copy head that owns that position, so it takes the position's overrides. The head was looked up among live components only. Inside a copy of a deleted component no head was found, and the restored copy kept the new component's values while its untouched position held others. Look the head up with deleted components included, as the direct sync it calls already does. A fresh JVM library run (seed 20261031) found this: a switched-back board lost an authored fill to the variant's white (I4). The direct regression fails its fill assertion before the fix (#FFFFFF for #333333) and passes after it. Full common passes lint, JVM, JavaScript and formatting: JVM 2065 tests / 33858 assertions; JavaScript 2001 / 32461. All six component properties pass 40 programs each at seed 712 in both runtimes. Full rebuilt frontend passes 1799 / 16286. Backend passes 1838 / 9293; exporter passes 16 / 40. Consumer lint and formatting pass. Compare lower-quantile milliseconds with the saved baseline; keep that baseline unchanged. The machine/JVM warning makes ratios rough. No world is flagged. World Baseline Now Ratio Main into 10 copies 1.790 0.935 0.52 Main into 100 copies 15.415 9.267 0.60 Main into 1000 copies 153.086 85.839 0.56 Three nesting levels 35.215 17.833 0.51 Dependency chain 68.931 35.026 0.51 Library update 83.083 43.812 0.53 Many plain shapes 4.837 2.182 0.45 Variant switch 32.052 20.841 0.65 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
9dc405b65e
commit
b14cec3c4f
@ -504,7 +504,8 @@
|
||||
parent (get objects (:parent-id shape))
|
||||
container (ctn/make-container (assoc page :objects objects) :page)]
|
||||
(if (and (:shape-ref parent) (not (ctk/swapped? shape)))
|
||||
(let [component (ctf/find-ref-component nil container libraries shape)
|
||||
(let [component (ctf/find-ref-component nil container libraries shape
|
||||
:include-deleted? true)
|
||||
head (d/seek #(= (:id component) (:component-id %))
|
||||
(ctn/get-parent-copy-heads objects parent))]
|
||||
(if head
|
||||
|
||||
@ -1079,3 +1079,14 @@
|
||||
(t/is (= (:fills head) (:fills (ths/get-shape-by-id full (:id head)))))
|
||||
(t/is (= (thn/normalize-file (tm/file edited))
|
||||
(thn/normalize-file (tm/file (r/step swapped (n/undo))))))))
|
||||
|
||||
(t/deftest swapping-back-in-a-copy-of-a-deleted-component-inherits-its-position
|
||||
(let [edited (-> (tm/make-situation (setup))
|
||||
(r/step (n/change-property :card-star :fills "#333333")) r/settle)
|
||||
deleted (-> edited (r/step (n/delete-component :card-main)) r/settle)
|
||||
swapped (-> deleted (r/step (n/swap-shape :copy-star :star)) r/settle)
|
||||
head (tm/resolve-shape swapped :copy-star)]
|
||||
(t/is (= "#333333" (get-in head [:fills 0 :fill-color])))
|
||||
(t/is (empty? (:touched head)))
|
||||
(t/is (= (thn/normalize-file (tm/file deleted))
|
||||
(thn/normalize-file (tm/file (r/step swapped (n/undo))))))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user