Add a flag to prevent section fields reset while using setFieldsValue #965
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist:
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
Since the
setFieldsValue
method and thehandleInput
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.Impact
setFieldsValue
andhandleInput
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.