Skip to content

fix(renderer): fix undefined meta in condition #1234

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
Apr 13, 2022

Conversation

rvsia
Copy link
Contributor

@rvsia rvsia commented Apr 13, 2022

Fixes #1233

Description

  • When a field is being unmounted (meta == false), we should finish the execution of condition setter.
  • instead of field.modified we should check the entire form.modified as we do not know what fields are triggering the condition (there is a memoized setter result + fieldListeners, so that ensures that the setter is not triggered when anything else changes after the first render, but it only listens to the correct changes)

Schema (if applicable)

    const schema = {
      fields: [
        {
          component: 'text-field',
          name: 'field1',
          initialValue: 'B',
        },
        {
          component: 'text-field',
          name: 'field2',
          initialValue: 'schema initial value',
          clearOnUnmount: true,
          condition: {
            when: 'field1',
            is: 'B',
            then: { set: { field2: 'set with then' } },
            else: { set: { field2: 'set with else' } },
          },
        },
      ],
    };

@rvsia rvsia added bug Something isn't working renderer React form renderer PR labels Apr 13, 2022
@rvsia rvsia requested a review from Hyperkid123 April 13, 2022 08:23
@DataDrivenFormsBot
Copy link

A new version (fix) will be released: v3.17.3 [DataDrivenFormsBot]

@rvsia rvsia force-pushed the fixSetterInitial branch from 5085b3c to 6fdc329 Compare April 13, 2022 08:32
@codecov
Copy link

codecov bot commented Apr 13, 2022

Codecov Report

Merging #1234 (6fdc329) into master (aa7fdf7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1234   +/-   ##
=======================================
  Coverage   95.07%   95.07%           
=======================================
  Files         209      209           
  Lines        3612     3613    +1     
  Branches     1261     1261           
=======================================
+ Hits         3434     3435    +1     
  Misses        178      178           
Impacted Files Coverage Δ
...ges/react-form-renderer/src/condition/condition.js 97.72% <100.00%> (+0.05%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@rvsia rvsia merged commit 5917bc3 into data-driven-forms:master Apr 13, 2022
@rvsia rvsia added the released label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released renderer React form renderer PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught TypeError
3 participants