mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Mark the constraints a swap pushed into a main keeps
Update main of a copy that swapped a nested copy, pushed inside a copy of the main, puts the swapped shapes in the position's place and points them at the position's subtree. Their differing content became overrides, but their constraints did not: a pushed icon kept the copy's fixed scroll while its new reference scrolls fixed, untouched and different from its main. A shape pushed below the head now marks its constraints group when its constraints differ from those of its new reference, keeping what the copy showed, as the head already does. The composable model expects that override. Test: generated `an-update-main-of-a-swap-keeps-the-constraints-its-children-showed`. Benchmark (bench-components, alone): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.399 | 22.081 | 0.61 | | edit-through-a-chain-of-dependents | 68.931 | 41.679 | 43.499 | 0.6 | | library-update-into-copies | 83.083 | 50.272 | 54.817 | 0.61 | | main-edit-among-many-shapes | 4.837 | 2.258 | 2.591 | 0.47 | | main-edit-into-10-copies | 1.79 | 1.034 | 1.071 | 0.58 | | main-edit-into-100-copies | 15.415 | 10.439 | 11.139 | 0.68 | | main-edit-into-1000-copies | 153.086 | 101.545 | 105.155 | 0.66 | | variant-switch-into-copies | 32.052 | 23.541 | 24.772 | 0.73 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
645223d90c
commit
2778039f10
@ -1459,6 +1459,17 @@
|
||||
(and main (some #(not= (get shape %) (get main %)) [:constraints-h :constraints-v :fixed-scroll]))
|
||||
(update :touched ctk/set-touched-group :constraints-group))))
|
||||
|
||||
(defn- author-pushed-constraints
|
||||
"A shape pushed below a swap keeps the constraints the copy showed,
|
||||
authored when they differ from those of its new `reference`."
|
||||
[shape reference]
|
||||
(cond-> shape
|
||||
(and reference
|
||||
(some #(not= (cond-> (get shape %) (= % :fixed-scroll) boolean)
|
||||
(cond-> (get reference %) (= % :fixed-scroll) boolean))
|
||||
[:constraints-h :constraints-v :fixed-scroll]))
|
||||
(update :touched ctk/set-touched-group :constraints-group)))
|
||||
|
||||
(defn- same-pushed-value?
|
||||
"Whether a pushed shape's `value` of `attr` shows as its reference's
|
||||
`other`: no fills or strokes and an empty list of them look the same."
|
||||
@ -1615,7 +1626,9 @@
|
||||
(let [shape (cond-> (follow-position shape)
|
||||
(and (= (:id shape) (:id new-head)) (seq placement))
|
||||
(update :touched (fnil into #{}) placement))]
|
||||
(author-pushed-content shape (get position-objects (:shape-ref shape)))))
|
||||
(cond-> (author-pushed-content shape (get position-objects (:shape-ref shape)))
|
||||
(not= (:id shape) (:id new-head))
|
||||
(author-pushed-constraints (get position-objects (:shape-ref shape))))))
|
||||
positioned))
|
||||
new-shapes)
|
||||
|
||||
|
||||
@ -572,6 +572,12 @@
|
||||
(not (same-value? shape :constraints-group (values content-main :constraints-group))))
|
||||
(assoc :constraints-group (values shape :constraints-group))
|
||||
|
||||
;; a shape below a pushed swap keeps the constraints the copy showed
|
||||
(and content? (not pushed-swap?) content-main
|
||||
(= (:component-id ref) (:component-id content-main))
|
||||
(not (same-value? shape :constraints-group (values content-main :constraints-group))))
|
||||
(assoc :constraints-group (values shape :constraints-group))
|
||||
|
||||
(seq placement)
|
||||
(merge (into {} (map (fn [group]
|
||||
[group (if (= :geometry-group group) geometry (values shape group))]))
|
||||
|
||||
@ -2469,6 +2469,16 @@
|
||||
:layout-copies false}]
|
||||
:ops [[:transform 0 10 0 8] [:apply-token 12 11] [:style 12 3 0 1] [:token-value 0 2]]}))))
|
||||
|
||||
(t/deftest an-update-main-of-a-swap-keeps-the-constraints-its-children-showed
|
||||
;; a swap pushed inside a copy of the main takes the place of a board whose
|
||||
;; icon scrolls fixed; the pushed icon keeps the copy's constraints as an
|
||||
;; override of its new reference
|
||||
(t/is (map? (cg/run {:world [3 2 {:variants true :text-styles true :layout nil :variant-diff false
|
||||
:layout-item-margins false :grid-square false :rich-variants true
|
||||
:layout-children false :grid-empty false :layout-copies true :text true}]
|
||||
:ops [[:variant-property 0 9 3 0] [:switch 4] [:combine 2] [:switch 8] [:style 11 7 1]
|
||||
[:update-main 2 0 0 0]]}))))
|
||||
|
||||
(t/deftest a-token-edit-keeps-the-square-corner-of-a-mirrored-copy
|
||||
;; a copy mirrored horizontally takes its main's radius tokens on the
|
||||
;; corners it shows them on, so a token edit leaves the corner its main
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user