You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be just an edge-case, not really an issue with the react-form itself. I still prefer to report this as I am not sure how can I solve it.
It seems like values provided by <Form values={} /> are not available through getValue() in FormInput on the "first run".
The input value is set to undefined when I am trying to setValue( getValue() ) in the onBlur callback without changing the input default value (it works when i change the value). I believe it should set the input value to its default value provided by <From values={ ... } /> instead of undefined.
Story:
I've created a custom input in which I verify the given value (in onBlur) and eventually change it. For example if the input value is 12 it will change to 12:00, 1:3 becomes01:30 and so on:
The default value specified in <Form values={...} /> matches the array-like field name and is displayed correctly as you can see:
When I click on the input and change it's value, everything works correctly. The input value is changed and eventually auto-corrected as intended.
The problem appears when I click on the input and then blur it without changing anything. Then it's value is changed to 00:00 (the default one returned by verifyValue), even if the input had a default value set by the <Form />:
I've tried to use some kinds of hacks, for example hard-setting the value directly in the input, but then the input becomes controlled (?) and I cannot change it's value anymore:
Any thoughts on how can I solve this issue? I am not sure if I am doing something wrong or if there's a problem with the way react-form handles defaults values provided by <Form />.
Using the latest Node.js and react-form version.
The text was updated successfully, but these errors were encountered:
Bartozzz
changed the title
Default input value disappears on setValue( getValue() )
Default input value disappears on setValue(getValue())
May 23, 2017
I am trying to debug this with React Devtools and I've found something strange.
Even if every input has a default value (which are by the way displayed correctly, see picture), only the first one has a value attribute in the component. When I click on another HourInput, a value property appears for the input I clicked on but dissapears on all others:
The first one has it's value set correctly:
This one should have value="23:59", but has nothing set:
This might be just an edge-case, not really an issue with the
react-form
itself. I still prefer to report this as I am not sure how can I solve it.It seems like values provided by
<Form values={} />
are not available throughgetValue()
inFormInput
on the "first run".The input value is set to
undefined
when I am trying tosetValue( getValue() )
in theonBlur
callback without changing the input default value (it works when i change the value). I believe it should set the input value to its default value provided by<From values={ ... } />
instead ofundefined
.Story:
I've created a custom input in which I verify the given value (in
onBlur
) and eventually change it. For example if the input value is12
it will change to12:00
,1:3
becomes01:30
and so on:Custom input:
<HourInput />
I am rendering those inputs in a loop, like so:
The default value specified in
<Form values={...} />
matches the array-like field name and is displayed correctly as you can see:When I click on the input and change it's value, everything works correctly. The input value is changed and eventually auto-corrected as intended.
The problem appears when I click on the input and then blur it without changing anything. Then it's value is changed to
00:00
(the default one returned byverifyValue
), even if the input had a default value set by the<Form />
:I've tried to use some kinds of hacks, for example hard-setting the value directly in the input, but then the input becomes controlled (?) and I cannot change it's value anymore:
Any thoughts on how can I solve this issue? I am not sure if I am doing something wrong or if there's a problem with the way
react-form
handles defaults values provided by<Form />
.Using the latest
Node.js
andreact-form
version.The text was updated successfully, but these errors were encountered: