Merge pull request #4482 from penpot/palba-fix-remove-swap-slot

Fixes on swap slots
This commit is contained in:
Alejandro 2024-04-22 13:20:28 +02:00 committed by GitHub
commit 8e9fa66e2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -386,7 +386,8 @@
(fn [new-shape original-shape] (fn [new-shape original-shape]
(let [new-name (:name new-shape) (let [new-name (:name new-shape)
root? (or (ctk/instance-root? original-shape) ; If shape is inside a component (not components-v2) root? (or (ctk/instance-root? original-shape) ; If shape is inside a component (not components-v2)
(nil? (:parent-id original-shape)))] ; we detect it by having no parent) (nil? (:parent-id original-shape))) ; we detect it by having no parent)
swap-slot (ctk/get-swap-slot original-shape)]
(when root? (when root?
(vswap! unames conj new-name)) (vswap! unames conj new-name))
@ -398,6 +399,9 @@
(-> (gsh/move delta) (-> (gsh/move delta)
(dissoc :touched)) (dissoc :touched))
(some? swap-slot)
(assoc :touched #{(ctk/build-swap-slot-group swap-slot)})
(and main-instance? root?) (and main-instance? root?)
(assoc :main-instance true) (assoc :main-instance true)

View file

@ -486,6 +486,7 @@
duplicating-component? (or duplicating-component? (ctk/instance-head? obj)) duplicating-component? (or duplicating-component? (ctk/instance-head? obj))
is-component-main? (ctk/main-instance? obj) is-component-main? (ctk/main-instance? obj)
subinstance-head? (ctk/subinstance-head? obj) subinstance-head? (ctk/subinstance-head? obj)
instance-root? (ctk/instance-root? obj)
into-component? (and duplicating-component? into-component? (and duplicating-component?
(ctn/in-any-component? objects parent)) (ctn/in-any-component? objects parent))
@ -508,7 +509,9 @@
:parent-id parent-id :parent-id parent-id
:frame-id frame-id) :frame-id frame-id)
(cond-> (and subinstance-head? remove-swap-slot?) (cond-> (and (not instance-root?)
subinstance-head?
remove-swap-slot?)
(ctk/remove-swap-slot)) (ctk/remove-swap-slot))
(dissoc :shapes (dissoc :shapes
@ -581,8 +584,9 @@
true true
(and remove-swap-slot? (and remove-swap-slot?
;; only remove swap slot of children when the current shape ;; only remove swap slot of children when the current shape
;; is not a subinstance head ;; is not a subinstance head nor a instance root
(not subinstance-head?)))) (not subinstance-head?)
(not instance-root?))))
changes changes
(map (d/getf objects) (:shapes obj))))))) (map (d/getf objects) (:shapes obj)))))))