fix: conditional fields perf bug - #2886#2890
Merged
Merged
Conversation
DanRibbens
approved these changes
Jun 22, 2023
Contributor
DanRibbens
left a comment
There was a problem hiding this comment.
LGTM! I haven't pulled it down, but I trust that the new test coverage is sufficient.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #2886
PR #2856 introduced a bug where conditional fields inside group/tab were causing infinite re-renders and not working correctly for group & tab fields.
In that PR we were attempting to use form state to see if fields have the flag
passesConditionon them. We were accessing them viafields[path]but fields such as group/tab do not have form state so they always returned false and the field never rendered.This PR proposes a different option where we pass a setter/callback function down to
<WatchCondition/>and that component will set the internal state on the<WithCondition/>component when it dispatches to form state.This also fixes a bug where conditions were being called incorrectly inside the fieldReducers
'MODIFY_CONDITION'action. It was passing flattened state but should have been passing the full unflattened object.Type of change
Checklist: