 
 (mx/defcs layer-group
   {:mixins [mx/static mx/reactive (mx/local)]}
-  [own item selected]
+  [own {:keys [id] :as item} selected]
   (let [local (:rum/local own)
         selected? (contains? selected (:id item))
-        open? (:open @local true)
-        select #(select-shape selected item %)
-        toggle-visibility #(toggle-visibility selected item %)
-        toggle-blocking #(toggle-blocking item %)
-        toggle-locking #(toggle-locking item %)
-        toggle-open (fn [event]
-                      (dom/stop-propagation event)
-                      (swap! local assoc :open (not open?)))
-        shapes-by-id (mx/react wb/shapes-by-id-ref)
+        collapsed? (:collapsed item true)
+        shapes-map (mx/react wb/shapes-by-id-ref)
         classes (classnames
                  :selected selected?
                  :drag-top (= :top (:over @local))
                  :drag-bottom (= :bottom (:over @local))
-                 :drag-inside (= :middle (:over @local)))]
-    (letfn [(on-drag-start [event]
+                 :drag-inside (= :middle (:over @local)))
+        select #(select-shape selected item %)
+        toggle-visibility #(toggle-visibility selected item %)
+        toggle-blocking #(toggle-blocking item %)]
+    (letfn [(toggle-collapse [event]
+              (dom/stop-propagation event)
+              (if (:collapsed item)
+                (rs/emit! (uds/uncollapse-shape id))
+                (rs/emit! (uds/collapse-shape id))))
+            (toggle-locking [event]
+              (dom/stop-propagation event)
+              (if (:locked item)
+                (rs/emit! (uds/unlock-shape id))
+                (rs/emit! (uds/lock-shape id))))
+            (on-drag-start [event]
               (let [target (dom/event->target event)]
                 (dnd/set-allowed-effect! event "move")
                 (dnd/set-data! event (:id item))

              (swap! local assoc :over true))
            (on-drag-leave [event]
              (swap! local assoc :over false))]
      [:li.group {:class (when open? "open")}
       [:div.element-list-body
        {:class classes
         :draggable true

    (if blocked?
      (rs/emit! (uds/unblock-shape id))
      (rs/emit! (uds/block-shape id)))))

(defn- element-icon
  [item]
