-
Notifications
You must be signed in to change notification settings - Fork 11.8k
fix: Save button remains in loading state after saving app settings #35394
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
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: ef85018 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 |
Hey @sushant52 , Thanks for identifying and fixing this issue. |
Hey @abhinavkrin I’ve added the changeset as requested. You can look |
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.72% 59.72%
========================================
Files 2829 2829
Lines 68243 68243
Branches 15126 15126
========================================
Hits 40759 40759
Misses 24876 24876
Partials 2608 2608
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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
CORE-1012
Steps to test or reproduce