mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
📎 Push a swap's authored geometry in its main's frame in the model
A copy root turned with its parent held a swapped child that authored its geometry, and update-main pushed the swap into the main. The child showed no turn against its root, so the main's new shape took none. The update-main model moved a pushed swap's geometry into the main's frame only when its turn differed from the one the main would give it; when the turns agreed it kept the copy's authored geometry, turned with the copy root, and expected that turn in the main. A pushed swap that authors its geometry now pushes it in the frame of its main. Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
ceb142f7a7
commit
c56c4cd4e7
@ -462,9 +462,11 @@
|
||||
(get before (:parent-id content-main))
|
||||
(get after (:parent-id ref))))
|
||||
groups (cond-> groups
|
||||
;; a pushed swap authors geometry in the frame of its main
|
||||
(and pushed-swap?
|
||||
(not (same-value? geometry :geometry-group
|
||||
(select-keys expected [:rotation :flip-x :flip-y]))))
|
||||
(or (contains? groups :geometry-group)
|
||||
(not (same-value? geometry :geometry-group
|
||||
(select-keys expected [:rotation :flip-x :flip-y])))))
|
||||
(assoc :geometry-group geometry)
|
||||
|
||||
(and pushed-swap?
|
||||
|
||||
@ -2403,6 +2403,24 @@
|
||||
(t/is (= 45 (:rotation expected)))
|
||||
(t/is (false? (shadow/same-value? (:pushed after) :geometry-group expected)))))
|
||||
|
||||
(t/deftest pushed-swap-shadow-leaves-out-the-turn-of-a-turned-copy-root
|
||||
(let [geometry {:width 100 :height 120 :rotation 45 :flip-x nil :flip-y nil :content-scale nil}
|
||||
before {:copy {:id :copy :shape-ref :main :component-root true :rotation 45 :shapes [:child]}
|
||||
:main {:id :main :component-root true :rotation 0}
|
||||
:child (merge {:id :child :parent-id :copy :component-id :target :shape-ref :position}
|
||||
geometry)
|
||||
:target-main {:id :target-main :component-id :target :parent-id :page
|
||||
:rotation 0 :width 100 :height 100}
|
||||
:page {:id :page :rotation 0}}
|
||||
after (-> before
|
||||
(assoc-in [:child :shape-ref] :pushed)
|
||||
(assoc :pushed (assoc (:target-main before) :id :pushed
|
||||
:shape-ref :target-main :parent-id :main)))
|
||||
model (shadow/update-main {:child {:swap-group {} :geometry-group geometry}} before after :copy)
|
||||
expected (get-in model [:pushed :geometry-group])]
|
||||
(t/is (= 0 (:rotation expected)))
|
||||
(t/is (= 120 (:height expected)))))
|
||||
|
||||
(t/deftest pushed-swap-shadow-predicts-content-without-reading-the-new-child
|
||||
(let [before {:copy {:id :copy :shape-ref :main :shapes [:child]}
|
||||
:main {:id :main}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user