Skip to content

fix(directory,admin): trim search whitespace in user search hooks#41561

Open
Sathvik2954 wants to merge 1 commit into
RocketChat:developfrom
Sathvik2954:fix/search-whitespace-trim
Open

fix(directory,admin): trim search whitespace in user search hooks#41561
Sathvik2954 wants to merge 1 commit into
RocketChat:developfrom
Sathvik2954:fix/search-whitespace-trim

Conversation

@Sathvik2954

@Sathvik2954 Sathvik2954 commented Jul 25, 2026

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Applies .trim() to search input terms in useDirectoryQuery and useFilteredUsers hooks.

This prevents search queries containing leading or trailing whitespace (e.g. " john ") from sending un-trimmed queries to the backend API, fixing user and channel lookup failures when extra spaces are present in search inputs.

Issue(s)

Closes #41545
Closes #41530

Steps to test or reproduce

  1. Navigate to Directory -> Users tab (or Workspace Admin -> Users).
  2. Enter a search query with leading or trailing spaces (e.g., admin ).
  3. Verify that the user list updates properly without failing to match users due to whitespace.

Further comments

  • Updated apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
  • Updated apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved user and directory searches by ignoring leading and trailing whitespace in search terms.
    • Prevents unintended spaces from affecting search results.

@Sathvik2954
Sathvik2954 requested a review from a team as a code owner July 25, 2026 01:46
@dionisio-bot

dionisio-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 32eab09

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2927a8b5-59f9-490d-a25c-eab9c442a218

📥 Commits

Reviewing files that changed from the base of the PR and between 6dc66fb and 32eab09.

📒 Files selected for processing (2)
  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
🧠 Learnings (5)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
  • apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts
🔇 Additional comments (2)
apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts (1)

13-13: LGTM!

apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts (1)

46-46: LGTM!


Walkthrough

User search inputs in Directory and Administration Users are trimmed before their client-side query payloads are built.

Changes

User search normalization

Layer / File(s) Summary
Trim user search queries
apps/meteor/client/views/directory/hooks/useDirectoryQuery.ts, apps/meteor/client/views/admin/users/hooks/useFilteredUsers.ts
Directory query text and Administration Users search terms now trim leading and trailing whitespace before requests are constructed. Internal whitespace remains unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: trimming whitespace in directory and admin user search hooks.
Linked Issues check ✅ Passed The PR trims leading and trailing whitespace in both Directory Users and Admin Users search hooks, matching issues #41545 and #41530.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to the two search hooks described in the linked issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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

Projects

None yet

1 participant