How to clear undo history

Tags: #<Tag:0x00007f8b19907648>

Hi all,

I wanted to clear undo history. I was going through the documentation and I found there is a clear() which will clear the undo history. But I don’t know how or where to implement it.

Can anyone please help me with my question.

Thank you.

Thank you for sharing this issue @aashayamballi

There’s a lack in the undoRedo documentation. It starts from the fact that we cannot use undoRedo via getPlugin() method, so we need to call its methods on the instance level. Example instance.undo().

However, when it comes to clear there is already one method called clear to erase the content. So when we call instance.undo() we call the method from the undoRedo plugin, but when we call instance.clear() we call clear() from core, not clear() from the undoRedo plugin.

As a workaround you can clear the doneActions array https://jsfiddle.net/a7d83bk9/ or access clear via plugin hot.undoRedo.clear()

I’ve mentioned the issue here https://github.com/handsontable/docs/issues/3#issuecomment-553834539

1 Like

Thank you so much for your reply. I will definitely try the workaround. :slight_smile: