Skip to content

Commit

Permalink
fix: remove unnecessary conditions in pointerup for linear elements (e…
Browse files Browse the repository at this point in the history
…xcalidraw#5575)

* fix: remove unnecessary conditions in pointerup for linear elements

* reset editingLinearElement when clicked inside bounding box
  • Loading branch information
ad1992 authored Aug 18, 2022
1 parent 38e8ae4 commit 551c38f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4534,9 +4534,8 @@ class App extends React.Component<AppProps, AppState> {
if (this.state.editingLinearElement) {
if (
!pointerDownState.boxSelection.hasOccurred &&
(pointerDownState.hit?.element?.id !==
this.state.editingLinearElement.elementId ||
!pointerDownState.hit.hasHitElementInside)
pointerDownState.hit?.element?.id !==
this.state.editingLinearElement.elementId
) {
this.actionManager.executeAction(actionFinalize);
} else {
Expand All @@ -4554,10 +4553,8 @@ class App extends React.Component<AppProps, AppState> {
}
} else if (this.state.selectedLinearElement) {
if (
!pointerDownState.boxSelection.hasOccurred &&
(pointerDownState.hit?.element?.id !==
this.state.selectedLinearElement.elementId ||
!pointerDownState.hit.hasHitElementInside)
pointerDownState.hit?.element?.id !==
this.state.selectedLinearElement.elementId
) {
const selectedELements = getSelectedElements(
this.scene.getNonDeletedElements(),
Expand Down Expand Up @@ -4937,7 +4934,6 @@ class App extends React.Component<AppProps, AppState> {
}

if (
!this.state.editingLinearElement &&
!pointerDownState.drag.hasOccurred &&
!this.state.isResizing &&
((hitElement &&
Expand All @@ -4950,13 +4946,16 @@ class App extends React.Component<AppProps, AppState> {
(!hitElement &&
pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements))
) {
// Deselect selected elements
this.setState({
selectedElementIds: {},
selectedGroupIds: {},
editingGroupId: null,
});

if (this.state.editingLinearElement) {
this.setState({ editingLinearElement: null });
} else {
// Deselect selected elements
this.setState({
selectedElementIds: {},
selectedGroupIds: {},
editingGroupId: null,
});
}
return;
}

Expand Down

0 comments on commit 551c38f

Please sign in to comment.