From 2fa00f39fc4ff1e0fbfd413391b61b3cf8d09081 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 1 Jan 2020 21:10:56 -0800 Subject: [PATCH] Automatically select last inserted element --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 30b3e224b..e214c91c2 100644 --- a/src/index.js +++ b/src/index.js @@ -219,6 +219,9 @@ function App() { id="canvas" width={window.innerWidth} height={window.innerHeight} + onClick={e => { + console.log("click"); + }} onMouseDown={e => { const x = e.clientX - e.target.offsetLeft; const y = e.clientY - e.target.offsetTop; @@ -255,12 +258,14 @@ function App() { drawScene(); }} onMouseUp={e => { - setDraggingElement(null); if (elementType === "selection") { // Remove actual selection element elements.pop(); setSelection(draggingElement); + } else { + draggingElement.isSelected = true; } + setDraggingElement(null); setElementType("selection"); drawScene(); }}