Fix #360 prevent creating invisibly small elements (#387)

This commit is contained in:
Günay Mert Karadoğan 2020-01-16 16:27:18 +00:00 committed by Christopher Chedeau
parent 2a8e562e98
commit 4ecc734659
1 changed files with 15 additions and 0 deletions

View File

@ -982,6 +982,21 @@ export class App extends React.Component<{}, AppState> {
window.removeEventListener("mousemove", onMouseMove);
window.removeEventListener("mouseup", onMouseUp);
if (
elementType !== "selection" &&
draggingElement &&
draggingElement.width === 0 &&
draggingElement.height === 0
) {
// remove invisible element which was added in onMouseDown
elements = elements.slice(0, -1);
this.setState({
draggingElement: null
});
this.forceUpdate();
return;
}
resetCursor();
// If click occured on already selected element