From 6743428ab8e2c019e6b46ce1403af77188131ce3 Mon Sep 17 00:00:00 2001 From: Max Girkens Date: Sun, 25 Feb 2024 09:04:53 +0100 Subject: [PATCH] undo fix --- src/App.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index a3f2c75..818dff2 100644 --- a/src/App.js +++ b/src/App.js @@ -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 = () => { @@ -321,6 +320,7 @@ function App () { Mousetrap.bind('z', e => { e.preventDefault() + resetSelection() undo() updateState({}) })