Skip to content

Conversation

@NAME-ASHWANIYADAV
Copy link
Contributor

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV commented Jan 26, 2026

Description

This PR refactors the CreateDiscussion component to utilize the standardized
GenericModal component from @rocket.chat/ui-client, replacing the manual
composition of Modal, ModalHeader, ModalContent, and ModalFooter.

This change addresses existing technical debt identified by a TODO comment in
CreateDiscussion.tsx and aligns the component with the codebase’s modern UI
patterns.

Additionally, this PR enhances GenericModal by introducing a
confirmLoading prop, enabling loading states on the confirmation button during
async operations such as creating a discussion.

Related issues

Changes proposed

  • Refactor CreateDiscussion.tsx to replace direct usage of Modal
    sub-components with GenericModal.
  • Enhance GenericModal.tsx by adding a confirmLoading prop to
    GenericModalProps and forwarding it to the primary action button.
  • Cleanup: Remove unused imports (Modal, ModalHeader, ModalTitle,
    ModalClose, ModalContent, ModalFooter).
  • Type safety: Remove the explicit ReactElement return type to improve type
    inference and resolve linting issues.

Verification steps

  1. Navigate to any channel or room.
  2. Open the Discussions tab from the Contextual Bar (or via the + menu).
  3. Click Create Discussion.
  4. Verify UI: The modal appears correctly with the title Create Discussion.
  5. Verify functionality: Fill in the details and click Create.
  6. Observe the loading spinner on the Create button
    (new confirmLoading functionality).
  7. Verify the discussion is created successfully and you are redirected to it.
  8. Verify cancellation: Click Cancel or close the modal and ensure it closes
    as expected.

Summary by CodeRabbit

  • New Features
    • Modal confirm buttons show a loading state during actions.
  • Refactor
    • Discussion creation dialog updated with a new modal container and streamlined form layout.
    • Parent-channel selection now uses a default field when applicable, otherwise an autocomplete selector.
    • Extended input props support in parent room field component for improved flexibility.
  • Bug Fixes
    • Form validations and enable/disable hints preserved and corrected for message/encryption interactions.
  • Tests
    • Added tests to verify modal confirm loading behavior.

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

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV requested a review from a team as a code owner January 26, 2026 08:54
@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

⚠️ No Changeset found

Latest commit: 2000012

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 26, 2026

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

  • This PR has conflicts, please resolve them before merging
  • This PR is not mergeable
  • This PR is targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Replaces the deprecated Modal in CreateDiscussion with GenericModal, adds a confirmLoading prop to GenericModal, and expands DefaultParentRoomField to accept and forward additional TextInput props; adjusts form wiring and room-selection logic accordingly.

Changes

Cohort / File(s) Summary
CreateDiscussion (modal refactor)
apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx
Replaced manual Modal composition with GenericModal; moved header/body/footer into GenericModal wrapperFunction; rewired form fields (name, topic, members, firstMessage, encrypted) and room selection to use DefaultParentRoomField when defaultParentRoom exists or RoomAutoComplete (via Controller) otherwise; removed explicit ReactElement return type.
GenericModal (API & tests)
packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx, packages/ui-client/src/components/Modal/GenericModal/GenericModal.spec.tsx
Added public prop confirmLoading?: boolean; pass loading={confirmLoading} to primary/Ok button and adjust onClick/submit behavior for wrapperFunction vs non-wrapper flows; added test asserting confirm button shows loading/disabled state.
DefaultParentRoomField (props forwarding)
apps/meteor/client/components/CreateDiscussion/DefaultParentRoomField.tsx
Changed props to DefaultParentRoomFieldProps (includes defaultParentRoom plus forwarded TextInput props excluding defaultValue/disabled); spread props into TextInput; extended room-name resolution to include name and prid.

Sequence Diagram(s)

(Skipped — changes are primarily a refactor and do not introduce a new multi-component control flow requiring visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • MartinSchoeler
  • dougfabris

🐰 Hooray, the modal hops anew,
GenericModal stitched through and through.
Buttons shimmer with patient light,
Room names pass props snug and tight.
A rabbit cheers this tidy view.

🚥 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 pull request title accurately describes the main change: refactoring CreateDiscussion to use GenericModal instead of manual Modal composition.
Linked Issues check ✅ Passed The pull request successfully addresses all objectives from issue #38333: replaces Modal with GenericModal in CreateDiscussion.tsx, aligns with standardized modal patterns, and adds confirmLoading support for async operations.
Out of Scope Changes check ✅ Passed Changes to GenericModal (confirmLoading prop) and DefaultParentRoomField (prop extension) are scope-appropriate enhancements supporting the CreateDiscussion refactor objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV changed the title Replace Modal with GenericModal in CreateDiscussion refactor: standardize CreateDiscussion modal using GenericModal Jan 26, 2026
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.

1 issue found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".changeset/add-emoji-keyword-search.md">

<violation number="1" location=".changeset/add-emoji-keyword-search.md:5">
P1: Unrelated changeset: declares emoji keyword search feature and minor meteor bump not present in this PR</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

1 issue found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx">

<violation number="1" location="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx:157">
P2: Submit path with `wrapperFunction` is treated as dismiss because `dismissedRef` is never cleared, leading to `onDismiss` firing after submit</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV force-pushed the refactor/38333-create-discussion-generic-modal branch from e1c615e to 298ce8e Compare January 27, 2026 06:09
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 112-123: FieldLabel's htmlFor is using parentRoomId but when
defaultParentRoom is rendered the DefaultParentRoomField isn't receiving that id
so the label-input association is broken; update the Controller rendering of
DefaultParentRoomField (inside the parentRoom Controller) to forward the
parentRoomId (or an aria-labelledby that references FieldLabel) as a prop and
ensure DefaultParentRoomField applies that prop to its internal input element so
the FieldLabel htmlFor matches the actual input id.

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: 2

🤖 Fix all issues with AI agents
In `@apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx`:
- Around line 217-223: The aria-describedby currently references
`${firstMessageId}-hint` even when `encrypted` is true and that hint element
isn't rendered; update the TextAreaInput in CreateDiscussion so aria-describedby
only includes the hint IDs that are actually rendered (i.e., include
`${firstMessageId}-hint` when not encrypted and include
`${firstMessageId}-encrypted-hint` when encrypted), apply the same conditional
logic to the other TextAreaInput usage noted (lines 227-231), and keep this
change within the CreateDiscussion component around the TextAreaInput props to
avoid broken ARIA references.
- Around line 161-167: The aria-describedby on the TextInput references
`${discussionNameId}-hint` but no hint element is rendered; either remove
`${discussionNameId}-hint` from the aria-describedby string or add a
visible/assistive hint element with that id next to the TextInput so the
reference is valid. Locate the TextInput usage (discussionNameId, field,
errors.name) and either (a) remove `${discussionNameId}-hint` from
aria-describedby leaving `${discussionNameId}-error` only, or (b) render a hint
element (e.g., a small help text element with id `${discussionNameId}-hint`)
adjacent to the input so assistive tech can resolve the reference.

- Update to warning variant with null icon
- Remove unused modalId variable
- Fix broken ARIA references for accessibility

Addresses feedback from @dougfabris in PR RocketChat#38334
@NAME-ASHWANIYADAV
Copy link
Contributor Author

@dougfabris All review comments addressed:

  • ✅ Updated to warning variant with icon={null}
  • ✅ Removed unused modalId
  • ✅ Fixed accessibility ARIA references

Ready for re-review!

@dougfabris
Copy link
Member

@NAME-ASHWANIYADAV Please make sure to check the lint issues and there some requests I did still pending

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.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx">

<violation number="1" location="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx:157">
P2: Wrapper function confirm no longer clears dismissedRef, so modal cleanup may fire onDismiss/onCancel after a successful submit.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@dougfabris dougfabris added this to the 8.2.0 milestone Jan 27, 2026
@NAME-ASHWANIYADAV
Copy link
Contributor Author

NAME-ASHWANIYADAV commented Jan 27, 2026

sorry my this pr takes a lot of your effort i will make sure to improve myself and contribute more efficient by getting more familiar with the code base
Thank you !! @dougfabris

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.78%. Comparing base (c6ec7a9) to head (2000012).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #38334   +/-   ##
========================================
  Coverage    70.77%   70.78%           
========================================
  Files         3159     3159           
  Lines       109401   109402    +1     
  Branches     19675    19672    -3     
========================================
+ Hits         77428    77436    +8     
+ Misses       29944    29934   -10     
- Partials      2029     2032    +3     
Flag Coverage Δ
e2e 60.36% <68.75%> (+0.03%) ⬆️
e2e-api 47.94% <ø> (+0.07%) ⬆️
unit 71.94% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dougfabris
Copy link
Member

dougfabris commented Jan 27, 2026

Not worries @NAME-ASHWANIYADAV this was a very nice work.
Thank you so much for the help!

@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Jan 27, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 27, 2026
dougfabris
dougfabris previously approved these changes Jan 27, 2026
Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

Thanks for the work here!

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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx">

<violation number="1" location="packages/ui-client/src/components/Modal/GenericModal/GenericModal.tsx:156">
P2: Confirm button now always renders; for non-form modals this creates duplicate “Ok” buttons or a non-functional confirm button when `wrapperFunction` is absent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@dougfabris
Copy link
Member

dougfabris commented Jan 27, 2026

why are you doing this? I approved your PR and you added more not related stuff?

@NAME-ASHWANIYADAV
Copy link
Contributor Author

NAME-ASHWANIYADAV commented Jan 27, 2026

Sorry about that @dougfabris— my mistake 🙏

I acted on a bot comment without realizing the PR was already approved.
You’re right, I shouldn’t have pushed additional changes at that stage.

If you prefer, I can:
• revert the last commit, or
• leave it as-is if you think the fix is acceptable.

Please let me know how you’d like me to proceed.

@dougfabris dougfabris force-pushed the refactor/38333-create-discussion-generic-modal branch from 904fdc8 to 1f33626 Compare January 27, 2026 19:25
Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

Don't worry, everything is ok now!

@kodiakhq kodiakhq bot removed the stat: ready to merge PR tested and approved waiting for merge label Jan 28, 2026
@kodiakhq
Copy link
Contributor

kodiakhq bot commented Jan 28, 2026

This PR currently has a merge conflict. Please resolve this and then re-add the ['stat: ready to merge', 'automerge'] label.

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

Labels

stat: conflict stat: QA assured Means it has been tested and approved by a company insider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Replace Modal usage with GenericModal in CreateDiscussion component

3 participants