Skip to content

Add a flag to prevent section fields reset while using setFieldsValue #965

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

Merged
merged 1 commit into from
Jun 17, 2025

Conversation

Bharatram-Santhanakrishnan
Copy link
Contributor

@Bharatram-Santhanakrishnan Bharatram-Santhanakrishnan commented Jun 12, 2025

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My commits have standard messages as mentioned in Contributing Guidelines

Overview

At present, if we set a section field and it's child fields using setFieldsValue, each update is treated as done by a user and handleInput logic is executed. As per the logic present there, if a section field value is changed, all the child fields are reset. This is a problem because it resets all the child fields that should be updated along with the section field.

Implementation

  1. As a fix, I have introduced a flag that can be passed as an argument to the setFieldsValue method. This would prevent the reset logic from being executed for updates done using this method when the argument (isManualUpdate) is passed.

Since the setFieldsValue method and the handleInput method are linked by a chain of emitted events, the flag passed would be kept active for a second under the assumption (and based on testing) that the events would be processed within this time period.

  1. There is also an enhancement done to the reset logic. Currently, the reset does not clear all the levels of a dependent field within a section. With this change, all the levels of a dependent field within a section is reset properly.

Impact

  1. Impacts setFieldsValue and handleInput method when called with the new argument. By default, the flag's value defaults to false and hence it won't impact any existing implementations.
  2. Reset logic now clears all levels of a dependent field.

Copy link
Collaborator

@prasanna-vijayan prasanna-vijayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Bharatram-Santhanakrishnan Bharatram-Santhanakrishnan marked this pull request as ready for review June 12, 2025 11:52
@prasanna-vijayan prasanna-vijayan merged commit 205234f into next Jun 17, 2025
7 checks passed
@prasanna-vijayan prasanna-vijayan deleted the add-flag-for-internal-update branch June 17, 2025 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants