Default value is not correctly updated for number input componenet

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.

Hi @joeBumbaca,

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.

Hi @joeBumbaca,

I'm able to replicate the bug and think the potential root cause maybe something about the URL setting. :thinking: 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.

STEP 2: Change from the edit mode to preview mode, the numberInput1 displays 100. The default value is displayed correctly so far.
STEP 3: Set the numberInput1 value to be a URL parameter.

STEP 4: 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.

STEP 5: 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!

Hi @joeBumbaca,

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?

Thank you!!

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!

1 Like

Hi @joeBumbaca,

The solution is working. Thank you again for the help!!

1 Like

No problem! Glad it's working for you!