-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: da9a7e2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 packages
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 |
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
apps/meteor/tests/e2e/code-setting-input-renders-one-text-area.spec.ts
Outdated
Show resolved
Hide resolved
apps/meteor/tests/e2e/code-setting-input-renders-one-text-area.spec.ts
Outdated
Show resolved
Hide resolved
@kody start-review |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
apps/meteor/client/views/admin/settings/Setting/inputs/CodeMirror/CodeMirror.tsx
Outdated
Show resolved
Hide resolved
|
There was a problem hiding this 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?
apps/meteor/client/views/admin/settings/Setting/inputs/CodeMirror/CodeMirror.tsx
Outdated
Show resolved
Hide resolved
apps/meteor/client/views/admin/settings/Setting/inputs/CodeMirror/CodeMirror.tsx
Show resolved
Hide resolved
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>
364ce28
to
1be2787
Compare
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
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:

After:

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:settingUpRef
to prevent multiple initializations of the CodeMirror component, which was causing the duplicate text boxes.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 filehonest-toys-guess.md
. The source branch for this fix isfix/code-setting-input-duplicate-textbox
, and it targets thedevelop
branch.