canUndo method returns true even after last annotation manipulated from historyManager

Hi,
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 .
code:
const historyManager = this.getHistoryManager();
if (historyManager.canUndo()) historyManager.undo();
this.isUndo = !historyManager.canUndo();
this.isRedo = false;

Thank you,
Vivek Sonawane

Hey there!

I cannot reproduce, but I believe its because undo() is async and you are not waiting for that promise to resolve.

const historyManager = this.getHistoryManager();
if (historyManager.canUndo()) {
   await historyManager.undo();
}
this.isUndo = !historyManager.canUndo();
this.isRedo = false;

The documentation does not state it is async, but we will fix that ASAP.

I hope this helps!
Thanks,
Logan