Compare commits

..

1 Commits

Author SHA1 Message Date
alonso.torres
71efa69ef8 🐛 Fix problem with flex.appendChild with naturalOrdering 2026-02-25 16:54:16 +01:00
2 changed files with 15 additions and 10 deletions

View File

@@ -10,12 +10,12 @@
[app.common.schema :as sm]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.transforms :as dwt]
[app.main.data.workspace.shapes :as dwsh]
[app.main.store :as st]
[app.plugins.flags :refer [natural-child-ordering?]]
[app.plugins.register :as r]
[app.plugins.utils :as u]
[app.util.object :as obj]
[potok.v2.core :as ptk]))
[app.util.object :as obj]))
;; Define in `app.plugins.shape` we do this way to prevent circular dependency
(def shape-proxy? nil)
@@ -259,9 +259,13 @@
(u/display-not-valid :appendChild child)
:else
(let [child-id (obj/get child "$id")]
(st/emit! (dwt/move-shapes-to-frame #{child-id} id nil nil)
(ptk/data-event :layout/update {:ids [id]})))))))
(let [child-id (obj/get child "$id")
shape (u/locate-shape file-id page-id id)
index
(if (and (natural-child-ordering? plugin-id) (not (ctl/reverse? shape)))
0
(count (:shapes shape)))]
(st/emit! (dwsh/relocate-shapes #{child-id} id index)))))))
(defn layout-child-proxy? [p]
(obj/type-of? p "LayoutChildProxy"))

View File

@@ -962,9 +962,10 @@
:else
(let [child-id (obj/get child "$id")
is-reversed? (ctl/flex-layout? shape)
index (if (and (natural-child-ordering? plugin-id) is-reversed?)
0
(count (:shapes shape)))]
index
(if (or (not (natural-child-ordering? plugin-id)) is-reversed?)
0
(count (:shapes shape)))]
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))))
:insertChild
@@ -987,7 +988,7 @@
(let [child-id (obj/get child "$id")
is-reversed? (ctl/flex-layout? shape)
index
(if (and (natural-child-ordering? plugin-id) is-reversed?)
(if (or (not (natural-child-ordering? plugin-id)) is-reversed?)
(- (count (:shapes shape)) index)
index)]
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))))