From ab84b5a048ea7f911def9e2a936f7be60a5454ae Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 1 Jan 2020 21:01:40 -0800 Subject: [PATCH] Go to selection mode after adding a shape --- src/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ede46070..8b31f0c1 100644 --- a/src/index.js +++ b/src/index.js @@ -144,6 +144,12 @@ function setSelection(selection) { }); } +function clearSelection() { + elements.forEach(element => { + element.isSelected = false; + }); +} + function App() { const [draggingElement, setDraggingElement] = React.useState(null); const [elementType, setElementType] = React.useState("selection"); @@ -188,7 +194,11 @@ function App() { setElementType(type)} + onChange={() => { + setElementType(type); + clearSelection(); + drawScene(); + }} /> {children} @@ -247,6 +257,7 @@ function App() { elements.pop(); setSelection(draggingElement); } + setElementType("selection"); drawScene(); }} onMouseMove={e => {