We have 2 buttons for undo and redo and after click on the respective buttons each time, we check for canUndo/canRedo methods to enable or disable these buttons. redo button works perfect but on undo button we need one extra click to disable it .
const historyManager = this.getHistoryManager();
if (historyManager.canUndo()) historyManager.undo();
this.isUndo = !historyManager.canUndo();
this.isRedo = false;