-
Notifications
You must be signed in to change notification settings - Fork 64
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
Run validation with updated resource values #139
Conversation
Codecov Report
@@ Coverage Diff @@
## main #139 +/- ##
==========================================
+ Coverage 59.27% 60.88% +1.60%
==========================================
Files 236 239 +3
Lines 4533 4704 +171
Branches 1079 1125 +46
==========================================
+ Hits 2687 2864 +177
+ Misses 1753 1747 -6
Partials 93 93
Continue to review full report at Codecov.
|
/retest |
/retest |
@@ -34,6 +35,8 @@ const ResourceLimitField: React.FC<ResourceLimitFieldProps> = ({ | |||
setFieldValue(props.name, val.value); | |||
setFieldTouched(props.name, true); | |||
setFieldValue(unitName, val.unit); | |||
// run validation manually so that formik uses the latest value | |||
validateForm(set(values, props.name, val.value)); |
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.
Maybe just validate the field with validateField
?
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.
Tried validateField
, it's still using the old value.
3b7fe24
to
dafbc09
Compare
/retest |
dafbc09
to
878caa3
Compare
/retest |
44429f2
to
73c69ba
Compare
/retest |
73c69ba
to
2b6e9cc
Compare
/retest |
2b6e9cc
to
cafd9ce
Compare
@@ -31,6 +32,8 @@ const ResourceLimitField: React.FC<ResourceLimitFieldProps> = ({ | |||
<RequestSizeInput | |||
{...props} | |||
onChange={(val) => { | |||
// run validation manually so that formik uses the latest value | |||
validateForm(set(values, props.name, val.value)); | |||
setFieldValue(props.name, val.value); |
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.
Have you tried this workaround? I tried it and it works for me.
setFieldValue(props.name, val.value); | |
setTimeout(() => setFieldValue(props.name, val.value)); |
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.
Thanks! Updated
cafd9ce
to
67427c6
Compare
@rottencandy: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rohitkrai03, rottencandy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes
https://issues.redhat.com/browse/HAC-1286
Description
Bug in formik causes validation to happen on the previous value instead of the updated value when
setFieldTouched
is used.I tried all workarounds from jaredpalmer/formik#2083 but this is the only one that worked.
Type of change
Screen shots / Gifs for design review
recording-1657203827.mp4
How to test or reproduce?
Try to add negative values in resource limit field.
Browser conformance: