diff --git a/common/uxbox/common/pages.cljc b/common/uxbox/common/pages.cljc index 9d3b38f52..5516592ab 100644 --- a/common/uxbox/common/pages.cljc +++ b/common/uxbox/common/pages.cljc @@ -440,9 +440,16 @@ (defmethod process-change :del-obj [data {:keys [id] :as change}] (when-let [{:keys [frame-id shapes] :as obj} (get-in data [:objects id])] - (let [data (update data :objects dissoc id)] + (let [objects (:objects data) + parent-id (get-parent id objects) + parent (get objects parent-id) + data (update data :objects dissoc id)] (cond-> data - (contains? (:objects data) frame-id) + (and (not= parent-id frame-id) + (= :group (:type parent))) + (update-in [:objects parent-id :shapes] (fn [s] (filterv #(not= % id) s))) + + (contains? objects frame-id) (update-in [:objects frame-id :shapes] (fn [s] (filterv #(not= % id) s))) (seq shapes) ; Recursive delete all dependend objects diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index c67ba08fd..a869298a9 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -659,18 +659,27 @@ ptk/WatchEvent (watch [_ state stream] (let [page-id (:current-page-id state) - session-id (:session-id state) objects (get-in state [:workspace-data page-id :objects]) cpindex (cp/calculate-child-parent-map objects) del-change #(array-map :type :del-obj :id %) + get-empty-parents + (fn get-empty-parents [id] + (let [parent (get objects (get cpindex id))] + (if (and (= :group (:type parent)) + (= 1 (count (:shapes parent)))) + (lazy-seq (cons (:id parent) + (get-empty-parents (:id parent)))) + nil))) + rchanges (reduce (fn [res id] (let [chd (cp/get-children id objects)] (into res (d/concat (mapv del-change (reverse chd)) - [(del-change id)])))) + [(del-change id)] + (map del-change (get-empty-parents id)))))) [] ids) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs index 224a66b17..a26ade504 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs @@ -153,9 +153,9 @@ (fn [side {:keys [id] :as data}] (if (= side :center) (st/emit! (dw/relocate-shape id (:id item) 0)) - (let [to-index (if (= side :top) (inc index) index) + (let [to-index (if (= side :top) (inc index) index) parent-id (cp/get-parent (:id item) objects)] - (st/emit! (dw/relocate-shape id parent-id to-index))))) + (st/emit! (dw/relocate-shape id parent-id to-index))))) on-hold (fn []