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

Code before:
          this.scene.getNonDeletedElements(),
          this.state,
        );

        if (selectedElements.length === 1) {
          const selectedElement = selectedElements[0];

          if (isLinearElement(selectedElement)) {
            if (
              !this.state.editingLinearElement ||
              this.state.editingLinearElement.elementId !==
                selectedElements[0].id
            ) {
              this.history.resumeRecording();
              this.setState({
                editingLinearElement: new LinearElementEditor(
                  selectedElement,
                  this.scene,
                ),
              });
            }
          } else if (
            isTextElement(selectedElement) ||
            isValidTextContainer(selectedElement)
          ) {
            const container = selectedElements[0] as ExcalidrawTextContainer;

            this.startTextEditing({
              sceneX: container.x + container.width / 2,
              sceneY: container.y + container.height / 2,

              container,
            });
            event.preventDefault();
            return;
          }
        }
      } else if (
        !event.ctrlKey &&
        !event.altKey &&
        !event.metaKey &&
        this.state.draggingElement === null
      ) {
        const shape = findShapeByKey(event.key);
        if (shape) {
          if (this.state.activeTool.type !== shape) {
            trackEvent(
              "toolbar",
              shape,
              `keyboard (${this.device.isMobile ? "mobile" : "desktop"})`,
            );

Review comment (suggestion):
this isn't correct. `selectedElement` can be a text element (= not a container) as per above condition.

Code after:
          this.scene.getNonDeletedElements(),
          this.state,
        );

        if (selectedElements.length === 1) {
          const selectedElement = selectedElements[0];

          if (isLinearElement(selectedElement)) {
            if (
              !this.state.editingLinearElement ||
              this.state.editingLinearElement.elementId !==
                selectedElements[0].id
            ) {
              this.history.resumeRecording();
              this.setState({
                editingLinearElement: new LinearElementEditor(
                  selectedElement,
                  this.scene,
                ),
              });
            }
          } else if (
            isTextElement(selectedElement) ||
            isValidTextContainer(selectedElement)
          ) {
            let container;
            if (!isTextElement(selectedElement)) {
              container = selectedElement as ExcalidrawTextContainer;
            }
            this.startTextEditing({
              sceneX: selectedElement.x + selectedElement.width / 2,
              sceneY: selectedElement.y + selectedElement.height / 2,
              container,
            });
            event.preventDefault();
            return;
          }
        }
      } else if (
        !event.ctrlKey &&
        !event.altKey &&
        !event.metaKey &&
        this.state.draggingElement === null
      ) {
        const shape = findShapeByKey(event.key);
        if (shape) {
          if (this.state.activeTool.type !== shape) {
            trackEvent(
              "toolbar",
              shape,
              `keyboard (${this.device.isMobile ? "mobile" : "desktop"})`,