CarlosNZ / json-edit-react

React component for editing/viewing JSON/object data
https://carlosnz.github.io/json-edit-react/
MIT License
183 stars 18 forks source link

Cancel button doesn't undo type change #122

Open kasijus opened 2 months ago

kasijus commented 2 months ago

Hi. I was wondering if this behavior was intended or if it's a bug: when I change a type of the value and then click the cancel button, it doesn't undo the type change. The issue can be seen in the recording below. I use version 1.16.1.

https://github.com/user-attachments/assets/98dd8128-4209-494d-9760-23f938685bbb

CarlosNZ commented 2 months ago

Yeah, it's an issue I'm aware of. Personally, I've always dealt with it by having Undo functionality.

The problem is due to the fact that each node manages its own state until you "Submit" at which time the main data structure is updated. But when you change type, it does the update immediately since it needs to render a different component.

It's probably not too hard to fix, but will require a little tinkering with the state structure. So far no one had mentioned it, so I hadn't bothered. But thanks for pointing it out, I'll add it to the "To-Do" list.

kasijus commented 2 months ago

Thanks @CarlosNZ for the feedback. I can also try to look into it and submit a PR, if that's ok.

CarlosNZ commented 2 months ago

Thanks @CarlosNZ for the feedback. I can also try to look into it and submit a PR, if that's ok.

Sure, good luck. I'll take a look in a week or two if no updates.