mirror of
https://github.com/penpot/penpot.git
synced 2026-09-14 07:59:36 +00:00
🐛 Fix detection of root in a particular case (affects many places)
This commit is contained in:
parent
42a0152c3a
commit
836781be42
@ -110,21 +110,25 @@
|
|||||||
"Get the parent top shape linked to a component for this shape, if any"
|
"Get the parent top shape linked to a component for this shape, if any"
|
||||||
([objects shape] (get-component-shape objects shape nil))
|
([objects shape] (get-component-shape objects shape nil))
|
||||||
([objects shape {:keys [allow-main?] :or {allow-main? false} :as options}]
|
([objects shape {:keys [allow-main?] :or {allow-main? false} :as options}]
|
||||||
(cond
|
(let [parent (get objects (:parent-id shape))]
|
||||||
(nil? shape)
|
(cond
|
||||||
nil
|
(nil? shape)
|
||||||
|
nil
|
||||||
|
|
||||||
(cfh/root? shape)
|
(cfh/root? shape)
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(ctk/instance-root? shape)
|
(ctk/instance-root? shape)
|
||||||
shape
|
shape
|
||||||
|
|
||||||
(and (not (ctk/in-component-copy? shape)) (not allow-main?))
|
(and (not (ctk/in-component-copy? shape)) (not allow-main?))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
:else
|
(and (ctk/instance-head? shape) (not (ctk/in-component-copy? parent)))
|
||||||
(get-component-shape objects (get objects (:parent-id shape)) options))))
|
shape ; This case is a copy root inside a main component
|
||||||
|
|
||||||
|
:else
|
||||||
|
(get-component-shape objects parent options)))))
|
||||||
|
|
||||||
(defn get-head-shape
|
(defn get-head-shape
|
||||||
"Get the parent top or nested shape linked to a component for this shape, if any"
|
"Get the parent top or nested shape linked to a component for this shape, if any"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user