Repository: excalidraw/excalidraw
File: packages/excalidraw/components/App.tsx (TypeScript)

Code before:
        ) {
          if (this.device.isTouchScreen) {
            const FIXED_DELTA_X = Math.min(
              (this.state.width * 0.7) / this.state.zoom.value,
              100,
            );

            this.scene.mutateElement(
              newElement,
              {
                x: newElement.x - FIXED_DELTA_X / 2,
                points: [
                  pointFrom<LocalPoint>(0, 0),
                  pointFrom<LocalPoint>(FIXED_DELTA_X, 0),
                ],
              },
              { informMutation: false, isDragging: false },
            );

            this.actionManager.executeAction(actionFinalize);
            this.setState({
              editingLinearElement: new LinearElementEditor(
                newElement,
                this.scene.getNonDeletedElementsMap(),
              ),
            });
          } else {
            const dx = pointerCoords.x - newElement.x;
            const dy = pointerCoords.y - newElement.y;

            this.scene.mutateElement(
              newElement,
              {
                points: [...newElement.points, pointFrom<LocalPoint>(dx, dy)],
              },
              { informMutation: false, isDragging: false },
            );

            this.setState({
              multiElement: newElement,
              newElement,
            });
          }
        } else if (pointerDownState.drag.hasOccurred && !multiElement) {
          if (
            isBindingEnabled(this.state) &&
            isBindingElement(newElement, false)
          ) {
            this.actionManager.executeAction(actionFinalize, "ui", {
              event: childEvent,
              sceneCoords,

Review comment (security):
this one currently has bad UX with pen input because it's pretty much impossible to exit the line editor by pointerdown with a pen. Not sure if it's because of the pen immediately box-selecting due to being oversensitive, or if we really prevent pen events to exit line editing. So we should fix it (e.g. add bigger threshold for box-selecting to not exit the editor while in line editor if that's the root cause).

NOTE that in prod it's still hard to exit with pen, but somewhat doable. In this PR it seems impossible, but I can't see which code change in this PR might be causing this...

Code after:
        ) {
          if (this.device.isTouchScreen) {
            const FIXED_DELTA_X = Math.min(
              (this.state.width * 0.7) / this.state.zoom.value,
              100,
            );

            this.scene.mutateElement(
              newElement,
              {
                x: newElement.x - FIXED_DELTA_X / 2,
                points: [
                  pointFrom<LocalPoint>(0, 0),
                  pointFrom<LocalPoint>(FIXED_DELTA_X, 0),
                ],
              },
              { informMutation: false, isDragging: false },
            );

            this.actionManager.executeAction(actionFinalize);
          } else {
            const dx = pointerCoords.x - newElement.x;
            const dy = pointerCoords.y - newElement.y;

            this.scene.mutateElement(
              newElement,
              {
                points: [...newElement.points, pointFrom<LocalPoint>(dx, dy)],
              },
              { informMutation: false, isDragging: false },
            );

            this.setState({
              multiElement: newElement,
              newElement,
            });
          }
        } else if (pointerDownState.drag.hasOccurred && !multiElement) {
          if (
            isBindingEnabled(this.state) &&
            isBindingElement(newElement, false)
          ) {
            this.actionManager.executeAction(actionFinalize, "ui", {
              event: childEvent,
              sceneCoords,
            });
          }
          this.setState({ suggestedBindings: [], startBoundElement: null });
          if (!activeTool.locked) {
            resetCursor(this.interactiveCanvas);
            this.setState((prevState) => ({