Skip to content

Number are not reset when exiting the text box #184

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

Open
BoBer78 opened this issue Apr 7, 2025 · 6 comments
Open

Number are not reset when exiting the text box #184

BoBer78 opened this issue Apr 7, 2025 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@BoBer78
Copy link

BoBer78 commented Apr 7, 2025

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 !

@BoBer78 BoBer78 added the bug Something isn't working label Apr 7, 2025
@CarlosNZ
Copy link
Owner

CarlosNZ commented Apr 7, 2025

Thanks for spotting this inconsistency, I'll fix ASAP!

@CarlosNZ
Copy link
Owner

CarlosNZ commented Apr 9, 2025

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!

@CarlosNZ CarlosNZ closed this as completed Apr 9, 2025
@BoBer78
Copy link
Author

BoBer78 commented Apr 10, 2025

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 99 in 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.

@CarlosNZ
Copy link
Owner

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.

@CarlosNZ CarlosNZ reopened this Apr 10, 2025
@CarlosNZ
Copy link
Owner

CarlosNZ commented May 7, 2025

@BoBer78 -- hey, just wondering if you're still seeing this in the latest version?

@BoBer78
Copy link
Author

BoBer78 commented May 13, 2025

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 json-edit-react@1.26.2, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants