json-edit-react icon indicating copy to clipboard operation
json-edit-react copied to clipboard

Cancel button doesn't undo type change

Open kasijus opened this issue 1 year ago • 3 comments

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

kasijus avatar Sep 11 '24 14:09 kasijus

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.

CarlosNZ avatar Sep 11 '24 21:09 CarlosNZ

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

kasijus avatar Sep 12 '24 08:09 kasijus

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.

CarlosNZ avatar Sep 12 '24 10:09 CarlosNZ

Have merged a fix for this to the main branch -- will close this issue after next release

CarlosNZ avatar Mar 08 '25 09:03 CarlosNZ

This is fixed now in v1.24.0

It's not quite perfect, as it does log two separate events in the Undo queue, but that's only relevant if you have an undo manager.

CarlosNZ avatar Mar 21 '25 01:03 CarlosNZ