From ec3be89ad4747310ab111a6797253354fc9c4993 Mon Sep 17 00:00:00 2001 From: Artur Tamborski Date: Fri, 27 Nov 2020 22:27:07 +0100 Subject: [PATCH] components/Board: ignore invalid selections --- src/components/Board/Board.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/Board/Board.tsx b/src/components/Board/Board.tsx index ee6e54b..dfdd7e7 100644 --- a/src/components/Board/Board.tsx +++ b/src/components/Board/Board.tsx @@ -41,6 +41,12 @@ export default class Board extends React.Component { } handleMouseUp(endPos: Point) { + const x = Math.abs(endPos.x - this.state.startPos.x); + const y = Math.abs(endPos.y - this.state.startPos.y); + + if (!(x === 0 || y === 0 || x === y)) + return; + this.setState({...this.state, endPos, isSelecting: false}); }