-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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: Save button remains in loading state after saving app settings #35394
base: develop
Are you sure you want to change the base?
fix: Save button remains in loading state after saving app settings #35394
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: 478f114 The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 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 |
Hey @sushant52 , Thanks for identifying and fixing this issue. |
Hey @abhinavkrin I’ve added the changeset as requested. You can look |
.changeset/fuzzy-eyes-clean.md
Outdated
'@rocket.chat/meteor': patch | ||
--- | ||
|
||
Fixes the save button loading state in the app settings page. The button now exits the loading state after settings are successfully saved. This resolves an issue where the button remained in a loading state indefinitely due to incorrect dependency on the `isSubmitted` state from `react-hook-form`. |
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.
Fixes the save button loading state in the app settings page. The button now exits the loading state after settings are successfully saved. This resolves an issue where the button remained in a loading state indefinitely due to incorrect dependency on the `isSubmitted` state from `react-hook-form`. | |
Fixes the save button loading state in app settings, ensuring it resets properly after saving. |
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.
Ok , I’ve made the changes
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.
After saving the settings, the footer which includes the save and cancel button should go away.
But currently it does not seem to be the case.
Screen.Recording.2025-03-05.at.3.21.33.PM.mov
Would suggest to reset the form in the saveAppSettings
function so that the isDirty state resets for the form.
const saveAppSettings = useCallback(
async (data: AppDetailsPageFormData) => {
try {
await AppClientOrchestratorInstance.setAppSettings(
id,
(Object.values(settings || {}) as ISetting[]).map((setting) => ({
...setting,
value: data[setting.id],
})),
);
reset(data); // reset form here
dispatchToastMessage({ type: 'success', message: `${name} settings saved succesfully` });
} catch (e: any) {
handleAPIError(e);
}
},
[dispatchToastMessage, id, name, reset, settings], // add to dependency
);
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #35394 +/- ##
========================================
Coverage 59.42% 59.42%
========================================
Files 2829 2829
Lines 68334 68334
Branches 15133 15133
========================================
Hits 40610 40610
Misses 25066 25066
Partials 2658 2658
Flags with carried forward coverage won't be shown. Click here to find out more. |
Thank you for pointing this out. I’ve implemented the fix. Let me know if there’s anything else I need to address |
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.
Looks good. Could you add tests for the fix? It is the last thing needed now. Tests make sure that such errors does not reoccur in future. Unit tests for AppDetailsPage.tsx ?
Hey, I have added unit tests . I’m still learning how to write tests, I’d appreciate it if you could review them and let me know if there’s anything I need to improve or adjust. |
2a8368e
to
86f79c1
Compare
86f79c1
to
2a8368e
Compare
Signed-off-by: Abhinav Kumar <[email protected]>
Proposed changes (including videos or screenshots)
This PR fixes an issue where the save button in the app settings page remains in a loading state even after the settings have been successfully saved. The issue occurs because the
loading
prop of the save button depends on bothisSubmitting
andisSubmitted
states fromreact-hook-form
. TheisSubmitted
state remainstrue
after submission, causing the button to stay in a loading state indefinitely.Before:
Screencast.2025-03-04.18.46.27.mp4
After:
https://github.com/user-attachments/assets/f81958e1-6e15-49cb-8b32-38dbec9aee4f
Issue(s)
Closes #35391
Steps to test or reproduce