Hi Retool team,
I'm using the number input component and set its default value to be a certain number. The expected result is that the component should be updated with the default value (ie. 20) if I don't change the component values. But the actual result is the component value is not set to be 20 and on the left side panel it shows the value to be "undefined".
Can you let me know how to fix it? Thank you in advance!
Hey doris.I! Can you share a little bit more about how this input gets set other than by the default value? I'd imagine that there is some other code being evaluated that is overriding the default value.
Thank you for the reply! Here's the input component info from the left and right-side panels.
The component is also used as a URL link parameter.
Let me know if the information is clear. Thank you.
I'm able to replicate the bug and think the potential root cause maybe something about the URL setting. Here is the replication process:
STEP 1: In a new Retool app, create a number input and set its default value to be 100. The value in the numberInput1 is updated to be 100 and the right side of the panel also shows the value to be 100.
: Change from the edit mode to preview mode, the numberInput1 displays 100. The default value is displayed correctly so far.
: Set the numberInput1 value to be a URL parameter.
: Change from edit mode to preview mode, the expected result is that the numberInput1 displays the default value (100), but the actual result is it shows 0. And the URL link should include the numberInput1 as a parameter but it is missing.
Change back to the edit mode to examine the issue, the numberInput1 displays 0 and the right side panel now shows the numberInput1 value to be "undefined".
Hope the additional information helps!
Want to follow up on this. Do you have any suggestions on how to set up the number input default value so the value is shown correctly on the preview mode and on the URL?
Hey doris.I, sorry for the delay. I was able to get this working in a slightly different way. You can set the default value for the numberInput when you are assigning the value to the input itself. The setup looks like this:
Here the urlparam and the value of the numberInput were both set correctly when switching back and forth from editor to preview mode. Hope this helps!
The solution is working. Thank you again for the help!!
No problem! Glad it's working for you!