mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 14:21:39 +02: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,6 +193,7 @@
|
||||||
new-main-instance-shape new-main-instance-shapes]
|
new-main-instance-shape new-main-instance-shapes]
|
||||||
(duplicate-component component new-component-id (:data library))]
|
(duplicate-component component new-component-id (:data library))]
|
||||||
|
|
||||||
|
[new-main-instance-shape
|
||||||
(-> changes
|
(-> changes
|
||||||
(pcb/with-page main-instance-page)
|
(pcb/with-page main-instance-page)
|
||||||
(pcb/with-objects (:objects main-instance-page))
|
(pcb/with-objects (:objects main-instance-page))
|
||||||
|
@ -206,7 +207,15 @@
|
||||||
[]
|
[]
|
||||||
(:id new-main-instance-shape)
|
(:id new-main-instance-shape)
|
||||||
(:id main-instance-page)
|
(:id main-instance-page)
|
||||||
(:annotation component)))))
|
(: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
|
(defn generate-instantiate-component
|
||||||
|
|
|
@ -286,7 +286,8 @@
|
||||||
component (thc/get-component file :component1)
|
component (thc/get-component file :component1)
|
||||||
|
|
||||||
;; ==== Action
|
;; ==== Action
|
||||||
changes (cll/generate-duplicate-component (pcb/empty-changes)
|
[_ changes]
|
||||||
|
(cll/generate-duplicate-component (pcb/empty-changes)
|
||||||
file
|
file
|
||||||
(:id component)
|
(:id component)
|
||||||
(uuid/next)
|
(uuid/next)
|
||||||
|
|
|
@ -529,10 +529,13 @@
|
||||||
(let [libraries (dsh/lookup-libraries state)
|
(let [libraries (dsh/lookup-libraries state)
|
||||||
library (get libraries library-id)
|
library (get libraries library-id)
|
||||||
components-v2 (features/active-feature? state "components/v2")
|
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
|
(defn delete-component
|
||||||
"Delete the component with the given id, from the current file library."
|
"Delete the component with the given id, from the current file library."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue