0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

🐛 Fix duplicate component

This commit is contained in:
Alejandro Alonso 2024-02-12 13:09:13 +01:00 committed by Andrés Moya
parent b9b66aee85
commit 90d6d38b47
3 changed files with 14 additions and 7 deletions

View file

@ -302,13 +302,19 @@
objects (:objects container) objects (:objects container)
unames (volatile! (cfh/get-used-names objects)) unames (volatile! (cfh/get-used-names objects))
component-children
(d/index-by :id (cfh/get-children-with-self objects (:id component-shape)))
frame-id (or force-frame-id frame-id (or force-frame-id
(ctst/get-frame-id-by-position objects (ctst/get-frame-id-by-position objects
(gpt/add orig-pos delta) (gpt/add orig-pos delta)
{:skip-components? true {:skip-components? true
:bottom-frames? true})) :bottom-frames? true
;; We must avoid that destiny frame is inside the component frame
:validator #(nil? (get component-children (:id %)))}))
frame (get-shape container frame-id) frame (get-shape container frame-id)
component-frame (get-component-shape (:objects container) frame {:allow-main? true}) component-frame (get-component-shape objects frame {:allow-main? true})
ids-map (volatile! {}) ids-map (volatile! {})

View file

@ -276,9 +276,12 @@
(gpt/point? position)) (gpt/point? position))
(let [frames (get-frames objects options) (let [frames (get-frames objects options)
frames (sort-z-index-objects objects frames options)] frames (sort-z-index-objects objects frames options)
;; Validator is a callback to add extra conditions to the suggested frame
validator (or (get options :validator) #(-> true))]
(or (d/seek #(and ^boolean (some? position) (or (d/seek #(and ^boolean (some? position)
^boolean (gsh/has-point? % position)) ^boolean (gsh/has-point? % position)
^boolean (validator %))
frames) frames)
(get objects uuid/zero))))) (get objects uuid/zero)))))

View file

@ -161,9 +161,7 @@
component component
(:data library) (:data library)
position position
components-v2 components-v2)
;; The position can generate a frame calculation inside the base component so we force the frame-id
{:force-frame-id frame-id})
first-shape (cond-> (first new-shapes) first-shape (cond-> (first new-shapes)
(not (nil? parent-id)) (not (nil? parent-id))