Skip to content

fix: conditional fields perf bug - #2886#2890

Merged
JarrodMFlesch merged 3 commits into
masterfrom
fix/2886-conditional-fields
Jun 22, 2023
Merged

fix: conditional fields perf bug - #2886#2890
JarrodMFlesch merged 3 commits into
masterfrom
fix/2886-conditional-fields

Conversation

@JarrodMFlesch
Copy link
Copy Markdown
Contributor

@JarrodMFlesch JarrodMFlesch commented Jun 22, 2023

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 passesCondition on them. We were accessing them via fields[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.

  • I have read and understand the CONTRIBUTING.md document in this repository

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

Copy link
Copy Markdown
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

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

LGTM! I haven't pulled it down, but I trust that the new test coverage is sufficient.

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.

Conditions not working in 1.10.0

2 participants