Skip to content

Commit

Permalink
undo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gherkins committed Feb 25, 2024
1 parent b8cd41b commit 6743428
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ function App () {
}

const undo = () => {
if (history.length > 0) {
setContents(history[history.length - 1])
history.pop()
resetSelection()
if (history.length <= 1) {
return false
}
setContents(history.pop())
}

const resetSelection = () => {
Expand Down Expand Up @@ -321,6 +320,7 @@ function App () {

Mousetrap.bind('z', e => {
e.preventDefault()
resetSelection()
undo()
updateState({})
})
Expand Down

0 comments on commit 6743428

Please sign in to comment.