RocketChat / RocketChat/Rocket.Chat

Home navbar search fails when search term contains leading or trailing whitespace

Open Beginner friendly
#41,604 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

The Home navbar search (Ctrl + K) does not return expected results when the search term contains leading or trailing whitespace.

For example, searching for general successfully finds the channel, but searching for general, general , or general returns no results. The same behavior is observed when searching for channels (#) and direct messages (@).

This causes valid searches to fail if users accidentally enter extra spaces before or after the search term.

Steps to reproduce:
  1. Open the Home navbar search (Ctrl + K).
  2. Search for an existing channel or user (e.g. general or @username).
  3. Repeat the search with leading or trailing whitespace, for example:
    • general
    • general
    • general
    • # general
    • @username
  4. Observe the search results.
Expected behavior:

Leading and trailing whitespace should be ignored, and the search should return the same results as the trimmed search term.

Actual behavior:

The search treats surrounding whitespace as part of the query, causing valid channels and users not to appear in the search results.

Server Setup Information:
  • Version of Rocket.Chat Server: 8.8.0-develop
  • License Type: Community
  • Number of Users: N/A
  • Operating System: Ubuntu 24.04 (WSL2)
  • Deployment Method: Development
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 22.22.3
  • MongoDB Version: 7.0.16
Client Setup Information
  • Desktop App or Browser Version: Google Chrome (latest)
  • Operating System: Windows 11
Additional context

This issue is reproducible with:

  • Channel searches
  • Direct message searches
  • Searches with leading whitespace
  • Searches with trailing whitespace
  • Searches with both leading and trailing whitespace

Examples:

Search Result
general ✅ Found
general ❌ Not found
general ❌ Not found
general ❌ Not found
#general ✅ Found
# general ❌ Not found
@username ✅ Found
@username ❌ Not found
Relevant logs:

No relevant server or browser errors are produced. The issue is reproducible consistently through normal UI interaction.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in the Home navbar search with the listed channel and direct-message queries, then trace the search input handling from that UI entry point. The work is done when leading and trailing whitespace is ignored and the trimmed, prefixed, and unprefixed examples return the same results as their clean queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.