diff --git a/src/uxbox/data/shapes.cljs b/src/uxbox/data/shapes.cljs index bcade26bb..7ceffd499 100644 --- a/src/uxbox/data/shapes.cljs +++ b/src/uxbox/data/shapes.cljs @@ -282,6 +282,16 @@ (-apply-update [_ state] (stsh/drop-shape state sid tid loc)))) +(defn select-first-shape + "Mark a shape selected for drawing in the canvas." + [] + (reify + rs/UpdateEvent + (-apply-update [_ state] + (let [page (get-in state [:workspace :page]) + id (first (get-in state [:pages-by-id page :shapes]))] + (assoc-in state [:workspace :selected] #{id}))))) + (defn select-shape "Mark a shape selected for drawing in the canvas." [id] diff --git a/src/uxbox/ui/workspace/drawarea.cljs b/src/uxbox/ui/workspace/drawarea.cljs index 312ee3589..63de16dce 100644 --- a/src/uxbox/ui/workspace/drawarea.cljs +++ b/src/uxbox/ui/workspace/drawarea.cljs @@ -89,7 +89,9 @@ (let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l) props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)} shape (ush/initialize shape props)] - (rs/emit! (uds/add-shape shape)))) + (rs/emit! (uds/add-shape shape) + (udw/select-for-drawing nil) + (uds/select-first-shape)))) (defn- initialize-shape-drawing "A drawing handler for generic shapes such as rect, circle, text, etc." @@ -102,7 +104,9 @@ (let [shape @drawing-shape shpos @drawing-position shape (ush/resize shape shpos)] - (rs/emit! (uds/add-shape shape)) + (rs/emit! (uds/add-shape shape) + (udw/select-for-drawing nil) + (uds/select-first-shape)) (reset! drawing-position nil) (reset! drawing-shape nil)))]