Skip to content

Bug : Crash when typing unknown slash command (e.g., /hello) #1144

@deepak0x

Description

@deepak0x

This PR fixes a crash that occurs when a user types an unknown slash command (e.g., /hello) and presses Enter.

Previously, entering a slash command that does not exist in the client-side commands list caused the application to crash with a TypeError. This PR ensures that the client handles unknown slash commands gracefully and aligns behavior with standard Rocket.Chat expectations.


Steps to Reproduce

  1. Open EmbeddedChat.
  2. Type /hello (or any unknown slash command) in the chat input.
  3. Press Enter.

Observed Behavior

The application crashes with the following error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'command')
    at CommandsList.js:33
    at HTMLDocument.handleKeyPress (CommandsList.js:54)
Image Image

Expected Behavior

  • The message /hello should be sent to the server.
  • The server should respond with No such command: /hello (standard Rocket.Chat behavior).
  • At a minimum, the client should not crash.
  • Add a defensive check to ensure selectedItem exists before accessing its properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions