Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CodeSettingInput renders duplicate code text box #35273

Merged
merged 11 commits into from
Mar 21, 2025

Conversation

abhinavkrin
Copy link
Member

@abhinavkrin abhinavkrin commented Feb 20, 2025

Proposed changes (including videos or screenshots)

This PR fixes an issue where the CodeSettingInput component renders the code text box twice.

The CodeMirror setup process is not instantaneous, causing a second call to create a duplicate code editor. To prevent this, a ref is used to track if an initialization is already in progress, ensuring it runs only once.

Before:
Screenshot 2025-02-20 at 6 54 26 PM

After:
Screenshot 2025-02-20 at 6 54 58 PM

Issue(s)

Steps to test or reproduce

Further comments

CORE-944


Pull Request Description

This pull request addresses an issue in the Rocket.Chat repository where the CodeSettingInput component was rendering duplicate code text boxes. The changes include:

  • Fix: The introduction of a settingUpRef to prevent multiple initializations of the CodeMirror component, which was causing the duplicate text boxes.
  • Improvement: Enhanced cleanup logic by verifying the existence of the parent node before invoking the toTextArea method, ensuring proper resource management and preventing potential errors.

These changes are implemented in the CodeMirror.tsx file and are documented in the changeset file honest-toys-guess.md. The source branch for this fix is fix/code-setting-input-duplicate-textbox, and it targets the develop branch.

@abhinavkrin abhinavkrin requested a review from a team as a code owner February 20, 2025 13:25
Copy link
Contributor

dionisio-bot bot commented Feb 20, 2025

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

  • This PR is targeting the wrong base branch. It should target 7.6.0, but it targets 7.5.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Feb 20, 2025

🦋 Changeset detected

Latest commit: da9a7e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

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

@abhinavkrin
Copy link
Member Author

I have created an e2e test instead of unit test since it was difficult to simulate the actual delay or runtime scenario to make the test fail in unit test.

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.73%. Comparing base (bffc49f) to head (da9a7e2).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #35273   +/-   ##
========================================
  Coverage    59.73%   59.73%           
========================================
  Files         2830     2830           
  Lines        68379    68379           
  Branches     15161    15161           
========================================
  Hits         40844    40844           
  Misses       24919    24919           
  Partials      2616     2616           
Flag Coverage Δ
unit 75.92% <ø> (ø)

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.

@abhinavkrin abhinavkrin added this to the 7.5.0 milestone Feb 20, 2025
@abhinavkrin
Copy link
Member Author

@kody start-review

Copy link

kodus-ai bot commented Mar 10, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization

Access your configuration settings here.

Copy link
Contributor

github-actions bot commented Mar 10, 2025

PR Preview Action v1.6.0

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35273/

Built to branch gh-pages at 2025-03-21 14:33 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

@abhinavkrin looking deeper to the code I think we could use a callbackRef instead of adding a third ref and useEffect. WDYT?

@abhinavkrin abhinavkrin requested a review from dougfabris March 19, 2025 11:07
@scuciatto scuciatto modified the milestones: 7.5.0, 7.6.0 Mar 20, 2025
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
@abhinavkrin abhinavkrin force-pushed the fix/code-setting-input-duplicate-textbox branch from 364ce28 to 1be2787 Compare March 20, 2025 12:00
@abhinavkrin abhinavkrin requested a review from dougfabris March 20, 2025 12:01
@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Mar 21, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Mar 21, 2025
@kodiakhq kodiakhq bot merged commit 05c567d into develop Mar 21, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/code-setting-input-duplicate-textbox branch March 21, 2025 16:08
abhinavkrin added a commit that referenced this pull request Mar 24, 2025
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
abhinavkrin added a commit that referenced this pull request Mar 24, 2025
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants