Skip to content

fix(react): fallback to channelName in ChatInput placeholder - #1459

Open
kafeelraza wants to merge 2 commits into
RocketChat:developfrom
kafeelraza:fix/chatinput-placeholder-undefined
Open

kafeelraza wants to merge 2 commits into
RocketChat:developfrom
kafeelraza:fix/chatinput-placeholder-undefined

Conversation

@kafeelraza

Copy link
Copy Markdown

Description

Fixes an issue where ChatInput placeholder rendered Message #undefined when channelInfo.name is not yet available (such as initial render before room fetch, anonymous mode, or Storybook).

Proposed Changes

  • Fallback to ECOptions.channelName or 'Type a message' if channelInfo.name is undefined.
  • Add changeset for @embeddedchat/react.

Testing Done

  • Tested in Storybook (EmbeddedChat/Simple).
  • Verified yarn build compiles cleanly.

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Hi @kafeelraza! Nice catch on preventing the Message #undefined flash before channel metadata finishes loading.

A few quick points and edge cases to consider:

  1. Direct Messages (channelInfo?.t === 'd'): For DMs, the room represents a direct conversation with a user rather than a channel. Prefixing with # yields Message #username instead of @username (or plain name).
  2. Thread input state: When replying within an active thread (threadId), the placeholder still says Message #${channelName}. It might be worth checking if a thread is active to display a thread-specific prompt (e.g. Reply in thread...).
  3. JSX Readability: The data-placeholder attribute is now 4 ternaries deep inside JSX. Moving this resolution into a computed variable or helper above the render block would make it much easier to read and maintain.
  4. Changeset formatting: The changeset file has a leading UTF-8 BOM character at byte 0; resaving it as standard UTF-8 without BOM will keep git diffs clean.

@kafeelraza

Copy link
Copy Markdown
Author

Thanks for the great feedback and edge-case catches, @swarnendusahu10-dotcom!

I've updated the PR with commit bf5006d6:

  1. Direct Messages: Added check for channelInfo?.t === 'd' to prefix with @ (Message @username) instead of #.
  2. Thread Input: Displaying Reply in thread... when replying inside an active thread (threadId).
  3. JSX Readability: Extracted the placeholder resolution into a clean useMemo hook above the render block.
  4. Changeset: Re-saved .changeset/fix-chatinput-placeholder.md as standard UTF-8 without BOM.

Verified that formatting checks and builds pass cleanly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants