-
Notifications
You must be signed in to change notification settings - Fork 592
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
fix(Field): getValues return initValue- #close 792 #807
Conversation
jdkahn
commented
Jun 20, 2019
- if getValues is called before init, should return initValue
- getIn, setIn unit tests
Codecov Report
@@ Coverage Diff @@
## feat/1.16.0 #807 +/- ##
===============================================
- Coverage 91.28% 84.72% -6.56%
===============================================
Files 244 244
Lines 14021 11287 -2734
Branches 4403 2806 -1597
===============================================
- Hits 12799 9563 -3236
+ Misses 1203 917 -286
- Partials 19 807 +788
Continue to review full report at Codecov.
|
src/field/index.js
Outdated
allValues = setIn(allValues, f, this.getValue(f)); | ||
} | ||
}); | ||
} else if (this.initValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can not do this, because people use reset or remove to clear all value.
and he expect to get {}, but return initValue.
hold for this PR, we need do big change to Field to make it use more friendly. |
- if getValues is called before init, should return initValue - getIn, setIn unit tests
- getValues should not return disabled field values
we should also update values while onChange trigged. |
- field.values is the new source of truth - field.fieldsMeta is for initialized components - disabled field support was broken, removed support
@@ -361,11 +375,21 @@ class Field { | |||
this.setValue(name, fieldsValue[name], false); | |||
}); | |||
} else { | |||
// NOTE: this is a shallow merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add NOTE:
we have two values a.b.c=1 ; a.b.d=2
, and use setValues({a:{b:{c:3}}}) , then because of shallow merge a.b.d
will lost, we will get only {a:{b:{c:3}}}