                           (and cpicker (.contains cpicker target)))
               (if selecting?
                 (mf/set-ref-val! selecting-ref false)
-                (on-close)))))
+                (on-close))))
+
+          (when (= 0 (content-size @content-var))
+            (st/emit! (dw/delete-shapes [id]))))
 
         on-mouse-down
         (fn [event]

        (fn [event]
          (dom/prevent-default event)
          (dom/stop-propagation event)
          (let [sidebar (dom/get-element "settings-bar")
                cpicker (dom/get-element-by-class "colorpicker-tooltip")
                self    (mf/ref-val self-ref)

    (mf/use-effect
     (mf/deps content)
     (fn []
       (reset! state (parse-content content))
       (reset! content-var content)))

    ;; Checks the size of the wrapper to update if it were necesary
    (mf/use-effect
