-
Notifications
You must be signed in to change notification settings - Fork 430
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
Support for preventing submit button when form content is not changed #8918
Comments
I have got a solution for that Capture the initial values of the form fields when the form is first loaded or reset. Each time a field is changed, compare the current value with the corresponding initial value for that specific field. Maintain a flag (like hasFormChanged) that tracks if any field has been modified compared to its initial value. If a field is changed back to its initial value, reset its modified state, ensuring hasFormChanged becomes false if all fields return to their original values. Compare individual fields rather than the entire form object (avoiding JSON.stringify), resulting in better performance and accuracy. Ensure that if a field is changed but reverted back to the original value, it doesn't falsely indicate that the form has changed. Can anyone assign me this issue? |
Let's have this feature in the This way all usages of the We could upgrade the |
yaa sure that would also work. |
I had made necessary changes in the form component. For other components like BedCapacity,StaffCapacity, etc we are not using Form component. So for that I had a solution by manually adding isDirty state to all component. |
let's switch those to use the Form component instead |
@kihan2518B can we also do the same for what's mentioned in #8982? |
Yaa sure I will make those component use the form component so that the issues are solved correspondingly |
Describe the bug
When attempting to update bed or staff details in the facilities section, clicking the "Update" button sends a request to the backend even if no changes have been made to the form. This results in unnecessary API calls, potentially leading to performance issues or confusion in tracking actual updates.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No request should be sent if no fields are updated, and the "Update" button should remain inactive.
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: