Number are not reset when exiting the text box
Describe the bug When editing an number, it does not reset when clicking elsewhere. The internal state is unchanged but what is displayed is.
Expected behavior See below screen recording. First behavior with numbers is incorrect. Second with strings is correct.
Screenshots https://github.com/user-attachments/assets/4afc8f9b-03e1-49b6-a174-5c4efa3a7295
Online demo The screen recording was made using the live demo.
Thanks for the great package by the way, very intuitive and super useful !
Thanks for spotting this inconsistency, I'll fix ASAP!
Should be fixed now in v1.25.1.
Thanks for reporting -- it was literally a one word error (just referring to the wrong variable), but it could have gone unnoticed for a long time!
Sorry to bother again, it seems like the issue is still unresolved. I tried locally and in the live demo on version v1.25.1.
Just to be clear, here are the steps to recreate :
- click on a number (for example the
99in the demo) - Enter a random value (valid one)
- Click on another field.
--> This will leave the number you entered shown on screen. It does not trigger validation nor sets the internal state. All the other field types (for example strings) are reset to their old value when you repeat the same steps.
This is not an urgent fix for us, just letting you know that the bug is still there.
Oh, that's annoying. At first I was unable to reproduce it on the demo, but I did it a few more times and eventually it happened. Damn, must be a race condition somewhere -- I'll have a closer look into it.
@BoBer78 -- hey, just wondering if you're still seeing this in the latest version?
Yes I still see the issue (locally and in in the demo), I will update this comment tomorrow with some video.
Update :
Here is what I get when using the live demo : https://github.com/user-attachments/assets/692d1c61-a94d-4b1e-8032-3b74712d9fd7
It might be intended behavior, but if I am editing a field and then click on another one, it changes without triggering the validation, nor setting the react state. If I click on the validate button after that, it will work. Before this was the case only with the numbers, now the strings have the same comportment.
The issue is that when I use your package in our app : https://github.com/user-attachments/assets/0f6a8f05-4544-4a10-9661-04e024d8ff3c
You can see that I changed some important value for a simulation. In particular the seed, time step and total time. When I accept, this is what is send to the server :
{'me_model_id':
[...]
'conditions__max_time': 100,
'conditions__time_step': 0.05,
'conditions__seed': 100}
The values have not been changed, what is displayed on json viewer is not matching was is saved in the React state.
For reference I am currently on version [email protected], and in my code I am using to manage the arguments state:
onUpdate={({ newData }) => {
const result = scsPostSchema.safeParse(newData);
if (!result.success) {
[...]
}
handleArgsChange(result.data);
}}
setData={(data: JsonData) => handleArgsChange(data)}
Everything works fine if I use the button to validate. As stated before, maybe this is the way that the package is intended to work.