mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 09:42:01 +00:00
🐛 Cancel a nested copy's parent turn in update main
Update main turned a copy back into its main's frame only when the copy root authored no geometry. A nested copy that inherited its parent's turn and then authored a resize still pushed the turn into its main, and sync composed it again: 45 degrees became 90. Sync composes a nested copy root with its parent's turn, so cancel exactly that turn, relative to the main's parent, whatever the root authors. A top-level copy root keeps the existing rule: it owns its turn only when it authors its geometry. The shrunk library program fails I9 before the fix and passes unchanged after it; the earlier inherited-turn regression still passes. Goldens are unchanged. Full suites ran on the tree with the fixture fix, this update-main fix and the grid rollout. Common JVM passes 2061 tests / 33765 assertions; JavaScript passes 1997 / 32400; common lint and formatting pass. All six component properties pass 40 programs each at seed 712 in both runtimes. Full rebuilt frontend passes 1798 / 16138. 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.866 0.48 Main into 100 copies 15.415 8.393 0.54 Main into 1000 copies 153.086 85.279 0.56 Three nesting levels 35.215 17.172 0.49 Dependency chain 68.931 34.199 0.50 Library update 83.083 42.833 0.52 Many plain shapes 4.837 2.064 0.43 Variant switch 32.052 19.599 0.61 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
80b65c8dbb
commit
9dc405b65e
@ -671,20 +671,28 @@
|
||||
(generate-rename-component (:component-id shape-inst) (:name shape-inst) library))]
|
||||
|
||||
(if component
|
||||
(let [synced-ids (volatile! #{})
|
||||
root-main (ctf/get-component-root library component)]
|
||||
(let [synced-ids (volatile! #{})
|
||||
main-container (ctf/get-component-container library component)
|
||||
root-main (ctf/get-component-root library component)
|
||||
center (grc/rect->center (:selrect shape-inst))]
|
||||
(-> (update-main-recursive changes
|
||||
{:container container
|
||||
:main-container (ctf/get-component-container library component)
|
||||
:main-container main-container
|
||||
:component component
|
||||
:libraries libraries
|
||||
:root-inst shape-inst
|
||||
:root-main root-main
|
||||
;; An orientation the copy root inherits from its
|
||||
;; parent places it; it is not pushed into the main.
|
||||
:inherited-turn (when-not (ctk/touched-group? shape-inst :geometry-group)
|
||||
(orient-like shape-inst root-main
|
||||
(grc/rect->center (:selrect shape-inst))))
|
||||
;; An orientation the copy root inherits places it
|
||||
;; and is not pushed into the main. Sync composes a
|
||||
;; nested root with its parent's turn; a top copy
|
||||
;; root owns its turn only when it authors geometry.
|
||||
:inherited-turn (if (:component-root shape-inst)
|
||||
(when-not (ctk/touched-group? shape-inst :geometry-group)
|
||||
(orient-like shape-inst root-main center))
|
||||
(when-let [parent (ctn/get-shape container (:parent-id shape-inst))]
|
||||
(orient-like parent
|
||||
(or (ctn/get-shape main-container (:parent-id root-main)) {})
|
||||
center)))
|
||||
:remote-synced (when-not (:component-root shape-inst) true)
|
||||
:synced-ids synced-ids}
|
||||
shape-inst
|
||||
|
||||
@ -696,6 +696,15 @@
|
||||
(t/is (true? (:fixed-scroll pushed)))
|
||||
(t/is (contains? (:touched pushed) :constraints-group))))
|
||||
|
||||
(t/deftest updating-a-main-from-a-resized-copy-turned-by-its-parent-keeps-its-turn
|
||||
;; The nested copy authors only its size; its 45 degree turn still comes
|
||||
;; from its parent, so update-main must not turn the main.
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :layout-item-margins false
|
||||
:library true :rich-variants true :layout-children false
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:transform 6 15 0 0] [:resize 0 0 0 0] [:resize 2 0 0 0] [:resize 1 0 0 0]
|
||||
[:edit 22 20 0 0] [:edit 11 0 1 1] [:update-main 11]]}))))
|
||||
|
||||
(t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides
|
||||
(t/is (map? (cg/run {:world [2 1 {:library true :variants true}]
|
||||
:ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user