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

Code before:
        this.setState({ isBindingEnabled: false });
      }

      if (isArrowKey(event.key)) {
        const selectedElements = this.scene.getSelectedElements({
          selectedElementIds: this.state.selectedElementIds,
          includeBoundTextElement: true,
          includeElementsInFrames: true,
        });

        const elbowArrow = selectedElements.find(isElbowArrow) as
          | ExcalidrawArrowElement
          | undefined;

        const preventKeyboardMove = selectedElements
          .filter(isElbowArrow)
          .find((arrow) => {
            const startMissing =
              arrow.startBinding &&
              !selectedElements.find(
                (el) => el.id === arrow.startBinding?.elementId,
              );
            const endMissing =
              arrow.endBinding &&
              !selectedElements.find(
                (el) => el.id === arrow.endBinding?.elementId,
              );
            return startMissing || endMissing;
          });

        const step = preventKeyboardMove
          ? 0
          : (this.getEffectiveGridSize() &&
              (event.shiftKey
                ? ELEMENT_TRANSLATE_AMOUNT
                : this.getEffectiveGridSize())) ||
            (event.shiftKey
              ? ELEMENT_SHIFT_TRANSLATE_AMOUNT
              : ELEMENT_TRANSLATE_AMOUNT);

        let offsetX = 0;
        let offsetY = 0;

        if (event.key === KEYS.ARROW_LEFT) {
          offsetX = -step;
        } else if (event.key === KEYS.ARROW_RIGHT) {
          offsetX = step;
        } else if (event.key === KEYS.ARROW_UP) {
          offsetY = -step;
        } else if (event.key === KEYS.ARROW_DOWN) {
          offsetY = step;

Review comment (suggestion):
Why check for this if in the `find()` predicate `el.id` will never equal `undefined` if the `endBinding` itself is `undefined`.

Code after:
        this.setState({ isBindingEnabled: false });
      }

      if (isArrowKey(event.key)) {
        let selectedElements = this.scene.getSelectedElements({
          selectedElementIds: this.state.selectedElementIds,
          includeBoundTextElement: true,
          includeElementsInFrames: true,
        });

        const elbowArrow = selectedElements.find(isElbowArrow) as
          | ExcalidrawArrowElement
          | undefined;

        const arrowIdsToRemove = new Set<string>();

        selectedElements
          .filter(isElbowArrow)
          .filter((arrow) => {
            const startElementNotInSelection =
              arrow.startBinding &&
              !selectedElements.some(
                (el) => el.id === arrow.startBinding?.elementId,
              );
            const endElementNotInSelection =
              arrow.endBinding &&
              !selectedElements.some(
                (el) => el.id === arrow.endBinding?.elementId,
              );
            return startElementNotInSelection || endElementNotInSelection;
          })
          .forEach((arrow) => arrowIdsToRemove.add(arrow.id));

        selectedElements = selectedElements.filter(
          (el) => !arrowIdsToRemove.has(el.id),
        );

        const step =
          (this.getEffectiveGridSize() &&
            (event.shiftKey
              ? ELEMENT_TRANSLATE_AMOUNT
              : this.getEffectiveGridSize())) ||
          (event.shiftKey
            ? ELEMENT_SHIFT_TRANSLATE_AMOUNT
            : ELEMENT_TRANSLATE_AMOUNT);

        let offsetX = 0;
        let offsetY = 0;

        if (event.key === KEYS.ARROW_LEFT) {
          offsetX = -step;