RocketChat / RocketChat/Rocket.Chat

Sidebar search triggers spotlight RPC for empty/whitespace queries

Open
#38,809 3 comments 0 reactions 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

Issue: Empty sidebar search should not call spotlight

Summary

When the sidebar search input is empty (or only contains spaces), the client still calls the spotlight method if the local result set is smaller than the configured limit.

This causes unnecessary server load and can return broad result sets that are not useful while the user has not typed a search term.

Impact

  • Extra spotlight traffic from idle/empty searches.
  • Increased backend workload during frequent search focus/open interactions.
  • Potentially noisy or unexpected results before the user provides intent.

Steps to reproduce

  1. Open the workspace sidebar search.
  2. Keep the query empty (or enter only whitespace).
  3. Observe network/method activity.
  4. spotlight is invoked despite no meaningful term being provided.

Expected behavior

  • Empty or whitespace-only searches should return local rooms only.
  • The spotlight method should be called only when there is a non-empty normalized term.

Proposed fix

Normalize the query term with trim() and short-circuit the queryFn to return localRooms when the normalized value is empty.

Status

Addressed in this branch by updating:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts

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 in apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts and inspect the queryFn used by the sidebar search. Verify that the query is normalized before deciding whether to call spotlight. Done means empty or whitespace-only queries return localRooms without invoking spotlight, while non-empty terms retain the existing search behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.