mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Combine a bool's shapes again after ungrouping inside it
A bool whose only child was a group kept, after ungrouping that group, the content it had made of the group: the outlines of its shapes one after the other, not the boolean result of them. The next refit of the bool, such as the undo of a later edit of one of its shapes, recomputed it, so that undo did not give back the state before the edit. An ungroup now refits the group or bool around the ungrouped shape, with the undo values of the refit. Tests: `groups-test/ungrouping-a-group-in-a-bool-combines-its-shapes-again` (fails before the fix), generated `an-ungroup-in-a-bool-combines-its-shapes-again`. The ungroup is outside the paths the component benchmark measures; it is not run. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
07427e39e7
commit
4eb537b3f7
@ -163,7 +163,9 @@
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/change-parent parent-id children index-in-parent options)
|
||||
(pcb/remove-objects [(:id group)] options)))))
|
||||
(pcb/remove-objects [(:id group)] options)
|
||||
;; a group or bool around takes the shapes as they now are
|
||||
(pcb/resize-parents [parent-id])))))
|
||||
|
||||
(defn remove-frame-changes
|
||||
([it page-id frame objects]
|
||||
@ -182,7 +184,9 @@
|
||||
(cond-> (ctl/any-layout? frame)
|
||||
(pcb/update-shapes (:shapes frame) ctl/remove-layout-item-data (select-keys options [:ignore-touched])))
|
||||
(pcb/change-parent parent-id children idx-in-parent options)
|
||||
(pcb/remove-objects [(:id frame)] options)))))
|
||||
(pcb/remove-objects [(:id frame)] options)
|
||||
;; a group or bool around takes the shapes as they now are
|
||||
(pcb/resize-parents [parent-id])))))
|
||||
|
||||
(defn ungroup-ids
|
||||
"The shapes of `ids` an ungroup takes apart: not inside a copy, not a
|
||||
|
||||
@ -2469,6 +2469,14 @@
|
||||
: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-ungroup-in-a-bool-combines-its-shapes-again
|
||||
;; ungrouping the group a bool combines makes the bool combine its shapes,
|
||||
;; so undoing a later edit gives the state before it
|
||||
(t/is (map? (cg/run {:world [2 0 {:variants true :rich-variants true :text true :layout nil :layout-copies true
|
||||
:layout-children false}]
|
||||
:ops [[:delete 3 0 0 0] [:structure 3 0 7 0] [:add-child 2] [:structure 2 5 0] [:delete 2]
|
||||
[:restore 2] [:swap 2 0 0 0] [:structure 3 2 0 0] [:text-style 2 0 1]]}))))
|
||||
|
||||
(t/deftest a-switched-head-in-a-copy-scales-with-its-parent
|
||||
;; the head authors the size the switch carried, which its copy parent's
|
||||
;; later resize scales through its constraint
|
||||
|
||||
@ -156,3 +156,22 @@
|
||||
objects (objects (thf/apply-changes file changes))]
|
||||
(t/is (= (-> (get objects (:id shape)) :selrect ((juxt :x :y :width :height)))
|
||||
(-> (get objects id) :selrect ((juxt :x :y :width :height)))))))
|
||||
|
||||
(t/deftest ungrouping-a-group-in-a-bool-combines-its-shapes-again
|
||||
(let [file (-> (thf/sample-file :file1)
|
||||
(ths/add-sample-shape :rect-a :width 50 :height 50)
|
||||
(ths/add-sample-shape :rect-b :width 70 :height 25))
|
||||
page (thf/current-page file)
|
||||
;; the bool its shapes make without the group
|
||||
[direct changes] (clb/generate-create-bool nil (:id page) (:objects page)
|
||||
[(thi/id :rect-a) (thi/id :rect-b)] :difference nil)
|
||||
expected (:content (get (objects (thf/apply-changes file changes)) (:id direct)))
|
||||
[id file] (group file [:rect-a :rect-b])
|
||||
page (thf/current-page file)
|
||||
[shape changes] (clb/generate-create-bool nil (:id page) (:objects page) [id] :difference nil)
|
||||
file (thf/apply-changes file changes)
|
||||
page (thf/current-page file)
|
||||
file (thf/apply-changes file (clg/generate-ungroup-changes nil (:id page) (:objects page) [id]))
|
||||
bool (get (objects file) (:id shape))]
|
||||
(t/is (= #{(thi/id :rect-a) (thi/id :rect-b)} (set (:shapes bool))))
|
||||
(t/is (= (str expected) (str (:content bool))))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user