mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
📎 Predict an unset attribute a switch carries as unset
A variant switch carries the copy's override of a group with the copy's values, an attribute the copy leaves unset included, as constraints the copy leaves to their default. The component model took the carried values with select-keys, which leaves out the attributes a shape does not store, so the new main's values showed through in the prediction. The carried attributes now take the copy's value, unset or not. Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
0ca00b7286
commit
00f40f8818
@ -764,7 +764,8 @@
|
||||
(assoc-in [(:id shape) group]
|
||||
(merge placed
|
||||
(when (and root? (= :geometry-group group)) position-orientation)
|
||||
(select-keys old carried)))))))
|
||||
;; an attribute the copy leaves unset carries as unset
|
||||
(into {} (map #(vector % (get old %))) carried)))))))
|
||||
result (cond->> (dissoc groups :swap-group)
|
||||
;; the head carries only its own layout item overrides
|
||||
(= root-id (:id shape))
|
||||
|
||||
@ -1807,6 +1807,13 @@
|
||||
:ops [[:duplicate 0 0 0 0] [:edit 2 2 0 1] [:combine 0] [:switch 0]
|
||||
[:update-main 0 0 0 0]]}))))
|
||||
|
||||
(t/deftest switching-a-copy-carries-the-constraints-it-leaves-unset
|
||||
(t/is (map? (cg/run {:world [2 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 0 0 0] [:switch 3] [:style 25 7 1] [:combine 0] [:switch 1]
|
||||
[:make-variant 19] [:switch 26]]}))))
|
||||
|
||||
(t/deftest random-variant-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user