refactor: remove unnecessary if condition for linear element onKeyDown (#5486)

* refactor: remove unnecessary if condition for linear element onKeyDown

* fix
This commit is contained in:
Aakansha Doshi 2022-07-26 16:33:13 +05:30 committed by GitHub
parent f8b4bb66b4
commit 339212e563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1872,35 +1872,32 @@ class App extends React.Component<AppProps, AppState> {
this.state, this.state,
); );
if ( if (selectedElements.length === 1) {
selectedElements.length === 1 && if (isLinearElement(selectedElements[0])) {
isLinearElement(selectedElements[0]) if (
) { !this.state.editingLinearElement ||
if ( this.state.editingLinearElement.elementId !==
!this.state.editingLinearElement || selectedElements[0].id
this.state.editingLinearElement.elementId !== selectedElements[0].id ) {
) { this.history.resumeRecording();
this.history.resumeRecording(); this.setState({
this.setState({ editingLinearElement: new LinearElementEditor(
editingLinearElement: new LinearElementEditor( selectedElements[0],
selectedElements[0], this.scene,
this.scene, ),
), });
}); }
} } else {
} else if ( const selectedElement = selectedElements[0];
selectedElements.length === 1 &&
!isLinearElement(selectedElements[0])
) {
const selectedElement = selectedElements[0];
this.startTextEditing({ this.startTextEditing({
sceneX: selectedElement.x + selectedElement.width / 2, sceneX: selectedElement.x + selectedElement.width / 2,
sceneY: selectedElement.y + selectedElement.height / 2, sceneY: selectedElement.y + selectedElement.height / 2,
shouldBind: true, shouldBind: true,
}); });
event.preventDefault(); event.preventDefault();
return; return;
}
} }
} else if ( } else if (
!event.ctrlKey && !event.ctrlKey &&