🐛 Fix problem moving shapes inside a group inside a layout

This commit is contained in:
alonso.torres 2023-01-18 14:34:58 +01:00
parent 9fd6c65d93
commit 89371e10d1
5 changed files with 20 additions and 13 deletions

View file

@ -359,7 +359,7 @@
to-reflow to-reflow
(cond-> to-reflow (cond-> to-reflow
(and (ctl/layout-child-id? objects current) (and (ctl/layout-descent? objects parent-base)
(not= uuid/zero (:frame-id parent-base))) (not= uuid/zero (:frame-id parent-base)))
(conj (:frame-id parent-base)))] (conj (:frame-id parent-base)))]
(recur modif-tree (recur modif-tree

View file

@ -6,6 +6,7 @@
(ns app.common.types.shape.layout (ns app.common.types.shape.layout
(:require (:require
[app.common.data.macros :as dm]
[app.common.spec :as us] [app.common.spec :as us]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
@ -99,15 +100,21 @@
([shape] ([shape]
(and (= :frame (:type shape)) (= :flex (:layout shape))))) (and (= :frame (:type shape)) (= :flex (:layout shape)))))
(defn layout-child? [objects shape] (defn layout-immediate-child? [objects shape]
(let [parent-id (:parent-id shape)
parent (get objects parent-id)]
(layout? parent)))
(defn layout-immediate-child-id? [objects id]
(let [parent-id (dm/get-in objects [id :parent-id])
parent (get objects parent-id)]
(layout? parent)))
(defn layout-descent? [objects shape]
(let [frame-id (:frame-id shape) (let [frame-id (:frame-id shape)
frame (get objects frame-id)] frame (get objects frame-id)]
(layout? frame))) (layout? frame)))
(defn layout-child-id? [objects id]
(let [shape (get objects id)]
(layout-child? objects shape)))
(defn inside-layout? (defn inside-layout?
"Check if the shape is inside a layout" "Check if the shape is inside a layout"
[objects shape] [objects shape]

View file

@ -440,7 +440,7 @@
exclude-frames-siblings exclude-frames-siblings
(into exclude-frames (into exclude-frames
(comp (mapcat (partial cph/get-siblings-ids objects)) (comp (mapcat (partial cph/get-siblings-ids objects))
(filter (partial ctl/layout-child-id? objects))) (filter (partial ctl/layout-immediate-child-id? objects)))
selected) selected)
fix-axis fix-axis
@ -640,7 +640,7 @@
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
selected (wsh/lookup-selected state {:omit-blocked? true}) selected (wsh/lookup-selected state {:omit-blocked? true})
selected-shapes (->> selected (map (d/getf objects)))] selected-shapes (->> selected (map (d/getf objects)))]
(if (every? (partial ctl/layout-child? objects) selected-shapes) (if (every? (partial ctl/layout-immediate-child-id? objects) selected-shapes)
(rx/of (reorder-selected-layout-child direction)) (rx/of (reorder-selected-layout-child direction))
(rx/of (nudge-selected-shapes direction shift?))))))) (rx/of (nudge-selected-shapes direction shift?)))))))

View file

@ -402,7 +402,7 @@
(let [objects (wsh/lookup-page-objects state)] (let [objects (wsh/lookup-page-objects state)]
(into [] (into []
(comp (map (d/getf objects)) (comp (map (d/getf objects))
(filter (partial ctl/layout-child? objects))) (filter (partial ctl/layout-immediate-child? objects)))
ids))) ids)))
st/state =)) st/state =))
@ -481,7 +481,7 @@
(fn [objects] (fn [objects]
(->> ids (->> ids
(map (d/getf objects)) (map (d/getf objects))
(some (partial ctl/layout-child? objects)))) (some (partial ctl/layout-immediate-child? objects))))
workspace-page-objects)) workspace-page-objects))
(defn get-flex-child-viewer (defn get-flex-child-viewer
@ -491,7 +491,7 @@
(let [objects (wsh/lookup-viewer-objects state page-id)] (let [objects (wsh/lookup-viewer-objects state page-id)]
(into [] (into []
(comp (map (d/getf objects)) (comp (map (d/getf objects))
(filter (partial ctl/layout-child? objects))) (filter (partial ctl/layout-immediate-child? objects)))
ids))) ids)))
st/state =)) st/state =))

View file

@ -82,7 +82,7 @@
grid-y-data (get-grids-snap-points frame :y)] grid-y-data (get-grids-snap-points frame :y)]
(cond-> page-data (cond-> page-data
(not (ctl/layout-child? objects frame)) (not (ctl/layout-descent? objects frame))
(-> ;; Update root frame information (-> ;; Update root frame information
(assoc-in [uuid/zero :objects-data frame-id] frame-data) (assoc-in [uuid/zero :objects-data frame-id] frame-data)
@ -106,7 +106,7 @@
:id (:id shape) :id (:id shape)
:pt %)))] :pt %)))]
(cond-> page-data (cond-> page-data
(not (ctl/layout-child? objects shape)) (not (ctl/layout-descent? objects shape))
(-> (assoc-in [frame-id :objects-data (:id shape)] shape-data) (-> (assoc-in [frame-id :objects-data (:id shape)] shape-data)
(update-in [frame-id :x] (make-insert-tree-data shape-data :x)) (update-in [frame-id :x] (make-insert-tree-data shape-data :x))
(update-in [frame-id :y] (make-insert-tree-data shape-data :y)))))) (update-in [frame-id :y] (make-insert-tree-data shape-data :y))))))