Howto undo the text

Hi,

I’ve activated undo/ redo. Due to some reason it’s not undoing the text field of a task. All other fields are undone.

Is there any special reason, do I have to configure something special?

Thx!

Andy

Hello,

Could you please elaborate the question? Do you mean undo/redo task text after changing it or something else?

Correct, when I perform an undo the task text is not undone/ redone. All other values are undone/ redone.

This issue isn’t reproduced in the sample:
docs.dhtmlx.com/gantt/samples/0 … _undo.html
Perhaps you have some custom development which changed default functionality. Please, check it.

Hi,

while I was researching on how this could happen, I figured out, that it’s concerned with my custom lightbox, which is build following your example on https://docs.dhtmlx.com/gantt/desktop__custom_edit_form.html.

If a task is updated like in your example the first object in the undo stack has the same values for oldValue and value where value is correct but oldValue contains the new values and not the old values.

To solve this issue I added a workaroud by storing the original task in a tempTask variable and modify the oldValue of the stack after gantt.updateTask.

This is how it looks like with full working undo/ redo with a custom lightbox:

var task = gantt.getTask(taskId); var tempTask = JSON.parse(JSON.stringify(task)); tempTask.start_date = new Date(tempTask.start_date); tempTask.end_date = new Date(tempTask.end_date); /* now the values of task are changed in the following lines */ /* e.g. task.text = lbox.text; */ gantt.updateTask(task.id); var index = gantt._undo._undoStack.length -1; gantt._undo._undoStack[index].commands[0].oldValue = tempTask;

Maybe this helps others who run into the same issue when using custom lightbox like in the sample mentioned above.

Best regards!

Andy

Hi,
Thank you for sharing the solution!