Skip to content

Conversation

@Dnyanesh-29
Copy link

@Dnyanesh-29 Dnyanesh-29 commented Jan 30, 2026

This PR introduces a validation check to the "Create Discussion" modal to prevent the creation of discussions with names consisting solely of whitespace (spaces or tabs).

Previously, the required rule only checked for empty strings, allowing users to bypass validation with spaces, which resulted in unnamed and unidentifiable rooms in the sidebar. I have added a custom validate rule using .trim() to ensure the name contains at least one non-whitespace character before submission.

Issue(s)
Closes #38434

Steps to test or reproduce
Click the + icon in the sidebar and select Create Discussion.

Select a Parent channel or team.

In the Name field, enter only spaces (e.g., " ").

Observe that the Create button now triggers a validation error ("The field Name is required") instead of successfully creating an unnamed discussion.

Further comments
I used the validate function within the Controller component to leverage the existing react-hook-form logic and the project's translation strings (t('Required_field', ...)), ensuring a consistent UI and localized error messages.

Summary by CodeRabbit

  • Bug Fixes

    • Added stricter validation to the discussion creation form name field to prevent empty or whitespace-only names.
    • Corrected the avatar URL input placeholder to a consistent example URL.
  • UI Improvements

    • Improved menu item icon layout with better centering and spacing for visual consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@Dnyanesh-29 Dnyanesh-29 requested a review from a team as a code owner January 30, 2026 06:36
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 30, 2026

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
Copy link

changeset-bot bot commented Jan 30, 2026

⚠️ No Changeset found

Latest commit: ec53e8b

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
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

Added trimmed-value validation to the CreateDiscussion name field to reject whitespace-only names; changed a placeholder URL in UserAvatarEditor to a hardcoded example; wrapped GenericMenuItem icon rendering in a Box for layout control.

Changes

Cohort / File(s) Summary
CreateDiscussion validation
apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx
Added validate rule to the Controller for name: `value.trim().length > 0
Avatar editor placeholder
apps/meteor/client/components/avatar/UserAvatarEditor/UserAvatarEditor.tsx
Replaced translated placeholder for image URL input with hardcoded example URL "https://example.com/avatar.png". (+1/-1)
GenericMenu icon layout
packages/ui-client/src/components/GenericMenu/GenericMenuItem.tsx
Imported Box and wrapped the icon rendering in a centered Box with fixed width, replacing direct icon output; formatting/indentation adjusted. (+14/-9)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • dougfabris

Poem

🐰
I trimmed the spaces hiding in the name,
No more empty rooms to cause surprise or shame.
A tiny Box holds icons in a row,
And a sample URL helps avatars show.
Hooray — hop forward, clean and tame! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements the core requirement from issue #38434 by adding trim-based validation to the name field, but includes unrelated changes to UserAvatarEditor and GenericMenuItem. Remove unrelated changes from UserAvatarEditor.tsx and GenericMenuItem.tsx that are not part of the whitespace validation fix for discussions.
Out of Scope Changes check ⚠️ Warning Changes to UserAvatarEditor.tsx (placeholder text) and GenericMenuItem.tsx (Box wrapper) are unrelated to the Create Discussion validation objective. Remove the UserAvatarEditor placeholder and GenericMenuItem icon wrapper changes, keeping only the CreateDiscussion.tsx validation logic.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change: adding whitespace validation to the Create Discussion name field to prevent unnamed discussions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx`:
- Around line 133-151: The parentRoom Controller currently has two render props
and the trim validate rule is applied to parentRoom instead of the name field;
fix this by removing the duplicate render prop from the Controller that uses
DefaultParentRoomField (ensure that Controller has name='parentRoom' and only
renders <DefaultParentRoomField defaultParentRoom={defaultParentRoom}
id={parentRoomId} />), and move the rules including validate: (value) =>
value.trim().length > 0 || t('Required_field', { field: t('Name') }) to the
Controller that renders the <TextInput id={discussionNameId} ... /> so the
Controller with name='name' enforces both required and trim validation (keep
aria and error props like aria-invalid={Boolean(errors.name)}).
🧹 Nitpick comments (1)
packages/ui-client/src/components/GenericMenu/GenericMenuItem.tsx (1)

1-26: Remove inline explanatory comments in implementation.

♻️ Proposed cleanup
-import { Box, MenuItemColumn, MenuItemContent, MenuItemIcon, MenuItemInput } from '@rocket.chat/fuselage'; // 1. Added Box import
+import { Box, MenuItemColumn, MenuItemContent, MenuItemIcon, MenuItemInput } from '@rocket.chat/fuselage';

-		{/* 2. Wrap the icon in a flexbox container */}
 		{icon && (
 			<Box display='flex' alignItems='center' justifyContent='center' width='x20'>
As per coding guidelines, Avoid code comments in the implementation.

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.

Discussion can be created with whitespace-only name

1 participant