Skip to content

[🐛] textComposer.setCommand causes command duplication after navigating away and back to a channel (v8.x) #3177

@arekkubaczkowski

Description

@arekkubaczkowski

Issue

After migrating to version 8.x of stream-chat-expo, I encountered a bug related to custom commands added using textComposer.setCommand.

🐛 Problem

When setting a custom command like this:

textComposer.setCommand({
  name: 'announcement',
  set: 'announcement',
  description: 'Send an announcement message',
});

If I follow these steps:
1. Enter a channel screen.
2. Send a message using the custom /announcement command (e.g. /announcement some text).
3. Navigate away from the screen.
4. Navigate back to the same channel screen.
5. Send another message with the same command.

The new message is sent with a duplicated command:

/announcement /announcement some text

Repeating the process (leave and re-enter the screen again) results in further duplication:

/announcement /announcement /announcement some text

This happens both with custom commands and built-in ones like /giphy.

🧪 Additional Observations
• The text input state appears to be persisting across screen navigations even though I am not using drafts.
• My chat client is configured with:

drafts: { enabled: false }

Yet, when I type something in the input, navigate away, and come back - the typed text remains.

✅ Expected Behavior
• The command should not duplicate across navigations.
• The input field should reset between navigations if drafts are disabled or not triggered explicitly.

I even tried to explicitly call textComposer.clearCommand() or textComposer.initState() after sending the message but nothing helps.

stream-chat-issue.mov

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error
    etc...

Expected behavior

Project Related Information

Customization

Click To Expand

# N/A

Offline support

  • I have enabled offline support.
  • The feature I'm having does not occur when offline support is disabled. (stripe out if not applicable)

Environment

Click To Expand

package.json:

# N/A

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • stream-chat-react-native version you're using that has this issue:
    • e.g. 5.4.3
  • Device/Emulator info:
    • I am using a physical device
    • OS version: e.g. Android 10
    • Device/Emulator: e.g. iPhone 11

Additional context

Screenshots

Click To Expand


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions