CarlosNZ/json-edit-react

Cancel button doesn't undo type change

Closed this issue · 5 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.

Screen.Recording.2024-09-11.164120.mp4

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.

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

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.

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

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.