From 339212e5638e3819bdb184dda24d03d491ffb1ec Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 26 Jul 2022 16:33:13 +0530 Subject: [PATCH] refactor: remove unnecessary if condition for linear element onKeyDown (#5486) * refactor: remove unnecessary if condition for linear element onKeyDown * fix --- src/components/App.tsx | 53 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 7a9240e9..541f14fb 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1872,35 +1872,32 @@ class App extends React.Component { this.state, ); - if ( - selectedElements.length === 1 && - isLinearElement(selectedElements[0]) - ) { - if ( - !this.state.editingLinearElement || - this.state.editingLinearElement.elementId !== selectedElements[0].id - ) { - this.history.resumeRecording(); - this.setState({ - editingLinearElement: new LinearElementEditor( - selectedElements[0], - this.scene, - ), - }); - } - } else if ( - selectedElements.length === 1 && - !isLinearElement(selectedElements[0]) - ) { - const selectedElement = selectedElements[0]; + if (selectedElements.length === 1) { + if (isLinearElement(selectedElements[0])) { + if ( + !this.state.editingLinearElement || + this.state.editingLinearElement.elementId !== + selectedElements[0].id + ) { + this.history.resumeRecording(); + this.setState({ + editingLinearElement: new LinearElementEditor( + selectedElements[0], + this.scene, + ), + }); + } + } else { + const selectedElement = selectedElements[0]; - this.startTextEditing({ - sceneX: selectedElement.x + selectedElement.width / 2, - sceneY: selectedElement.y + selectedElement.height / 2, - shouldBind: true, - }); - event.preventDefault(); - return; + this.startTextEditing({ + sceneX: selectedElement.x + selectedElement.width / 2, + sceneY: selectedElement.y + selectedElement.height / 2, + shouldBind: true, + }); + event.preventDefault(); + return; + } } } else if ( !event.ctrlKey &&