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

Code before:
      } else if (
        !event.ctrlKey &&
        !event.altKey &&
        !event.metaKey &&
        this.state.draggingElement === null
      ) {
        const shape = findShapeByKey(event.key);
        if (shape) {
          this.selectShapeTool(shape);
        } else if (event.key === KEYS.Q) {
          this.toggleLock();
        }
      }
      if (event.key === KEYS.SPACE && gesture.pointers.size === 0) {
        isHoldingSpace = true;
        setCursor(this.canvas, CURSOR_TYPE.GRABBING);
      }

      if (event.key === KEYS.G || event.key === KEYS.S) {
        const selectedElements = getSelectedElements(
          this.scene.getElements(),
          this.state,
        );
        if (
          this.state.elementType === "selection" &&
          selectedElements.length === 0
        ) {
          return;
        }

        if (
          event.key === KEYS.G &&
          (hasBackground(this.state.elementType) ||
            selectedElements.some((element) => hasBackground(element.type)))
        ) {
          this.setState({ openPopup: "backgroundColorPicker" });
        }
        if (event.key === KEYS.S) {
          this.setState({ openPopup: "strokeColorPicker" });
        }
      }
    },
  );

  private onKeyUp = withBatchedUpdates((event: KeyboardEvent) => {
    if (event.key === KEYS.SPACE) {
      if (this.state.viewModeEnabled) {
        setCursor(this.canvas, CURSOR_TYPE.GRAB);
      } else if (this.state.elementType === "selection") {
        resetCursor(this.canvas);
      } else {

Review comment (suggestion):
```suggestion
          !selectedElements.length
```

I believe this was GH Copilot's fault :)

Code after:
      } else if (
        !event.ctrlKey &&
        !event.altKey &&
        !event.metaKey &&
        this.state.draggingElement === null
      ) {
        const shape = findShapeByKey(event.key);
        if (shape) {
          this.selectShapeTool(shape);
        } else if (event.key === KEYS.Q) {
          this.toggleLock();
        }
      }
      if (event.key === KEYS.SPACE && gesture.pointers.size === 0) {
        isHoldingSpace = true;
        setCursor(this.canvas, CURSOR_TYPE.GRABBING);
      }

      if (event.key === KEYS.G || event.key === KEYS.S) {
        const selectedElements = getSelectedElements(
          this.scene.getElements(),
          this.state,
        );
        if (
          this.state.elementType === "selection" &&
          !selectedElements.length
        ) {
          return;
        }

        if (
          event.key === KEYS.G &&
          (hasBackground(this.state.elementType) ||
            selectedElements.some((element) => hasBackground(element.type)))
        ) {
          this.setState({ openPopup: "backgroundColorPicker" });
        }
        if (event.key === KEYS.S) {
          this.setState({ openPopup: "strokeColorPicker" });
        }
      }
    },
  );

  private onKeyUp = withBatchedUpdates((event: KeyboardEvent) => {
    if (event.key === KEYS.SPACE) {
      if (this.state.viewModeEnabled) {
        setCursor(this.canvas, CURSOR_TYPE.GRAB);
      } else if (this.state.elementType === "selection") {
        resetCursor(this.canvas);
      } else {