mirror of
https://github.com/penpot/penpot.git
synced 2025-04-06 20:11:29 -05:00
🐛 Fix problem updating layout when duplicating component
This commit is contained in:
parent
6d40166de7
commit
052282cff9
3 changed files with 35 additions and 22 deletions
|
@ -193,20 +193,29 @@
|
|||
new-main-instance-shape new-main-instance-shapes]
|
||||
(duplicate-component component new-component-id (:data library))]
|
||||
|
||||
(-> changes
|
||||
(pcb/with-page main-instance-page)
|
||||
(pcb/with-objects (:objects main-instance-page))
|
||||
(pcb/add-objects new-main-instance-shapes {:ignore-touched true})
|
||||
(pcb/add-component (if components-v2
|
||||
new-component-id
|
||||
(:id new-component-shape))
|
||||
(:path component)
|
||||
new-name
|
||||
new-component-shapes
|
||||
[]
|
||||
(:id new-main-instance-shape)
|
||||
(:id main-instance-page)
|
||||
(:annotation component)))))
|
||||
[new-main-instance-shape
|
||||
(-> changes
|
||||
(pcb/with-page main-instance-page)
|
||||
(pcb/with-objects (:objects main-instance-page))
|
||||
(pcb/add-objects new-main-instance-shapes {:ignore-touched true})
|
||||
(pcb/add-component (if components-v2
|
||||
new-component-id
|
||||
(:id new-component-shape))
|
||||
(:path component)
|
||||
new-name
|
||||
new-component-shapes
|
||||
[]
|
||||
(:id new-main-instance-shape)
|
||||
(:id main-instance-page)
|
||||
(:annotation component))
|
||||
;; Update grid layout if the new main instance is inside
|
||||
(pcb/update-shapes
|
||||
[(:frame-id new-main-instance-shape)]
|
||||
(fn [shape objects]
|
||||
(cond-> shape
|
||||
(ctl/grid-layout? shape)
|
||||
(ctl/assign-cells objects)))
|
||||
{:with-objects? true}))]))
|
||||
|
||||
|
||||
(defn generate-instantiate-component
|
||||
|
|
|
@ -286,11 +286,12 @@
|
|||
component (thc/get-component file :component1)
|
||||
|
||||
;; ==== Action
|
||||
changes (cll/generate-duplicate-component (pcb/empty-changes)
|
||||
file
|
||||
(:id component)
|
||||
(uuid/next)
|
||||
true)
|
||||
[_ changes]
|
||||
(cll/generate-duplicate-component (pcb/empty-changes)
|
||||
file
|
||||
(:id component)
|
||||
(uuid/next)
|
||||
true)
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
|
||||
|
|
|
@ -529,10 +529,13 @@
|
|||
(let [libraries (dsh/lookup-libraries state)
|
||||
library (get libraries library-id)
|
||||
components-v2 (features/active-feature? state "components/v2")
|
||||
changes (-> (pcb/empty-changes it nil)
|
||||
(cll/generate-duplicate-component library component-id new-component-id components-v2))]
|
||||
|
||||
(rx/of (dch/commit-changes changes)))))))
|
||||
[main-instance changes]
|
||||
(-> (pcb/empty-changes it nil)
|
||||
(cll/generate-duplicate-component library component-id new-component-id components-v2))]
|
||||
(rx/of
|
||||
(ptk/data-event :layout/update {:ids [(:id main-instance)]})
|
||||
(dch/commit-changes changes)))))))
|
||||
|
||||
(defn delete-component
|
||||
"Delete the component with the given id, from the current file library."
|
||||
|
|
Loading…
Add table
Reference in a new issue