Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

Go to selection mode after adding a shape

Christopher Chedeauab84b5a048ea
diff --git a/src/index.js b/src/index.js
index ede46070ee..8b31f0c14b 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() {
<input
type="radio"
checked={elementType === type}
- onChange={() => setElementType(type)}
+ onChange={() => {
+ setElementType(type);
+ clearSelection();
+ drawScene();
+ }}
/>
{children}
</label>
@@ -247,6 +257,7 @@ function App() {
elements.pop();
setSelection(draggingElement);
}
+ setElementType("selection");
drawScene();
}}
onMouseMove={e => {