Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undo/redo exception when there are no stored elements #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryphill
Copy link

@ryphill ryphill commented Jul 7, 2018

Right now there are two problems with undo and redo. One is that when redoaction runs and storedUndo is empty it pushes undefined into storedElement which will cause a type error. A similar thing will happen on undoaction with undefined being pushed onto storedUndo except a type error won't occur until you click redo.

I created a jsbin to demonstrate the problem. If you click undo you can see on the console that undefined gets added to storedUndo and if you click redo undefined is added to storedElement as well as a type error.

The other problem is that the undo and redo buttons aren't being disabled because they are not found when checkUndoRedo is called as children searches the direct children of the current element.

Technically, fixing the undo/redo buttons getting disabled would prevent the first problem from occurring but I added a fix to prevent adding undefined to storedUndo and storedElement just to be safe.

- undoaction and redoaction would push undefined onto storedUndo
and storedElement respectively if the other was empty when the
action was triggered. This would cause an exception on redo during
the redraw.
- Fixes undo and redo buttons not being disabled by using find
instead of children because they are not direct children of $tool.
- Adds annotate-undo and annotate-redo to the respective buttons
when the tool does not use bootstrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant