From 9929a2be6f5881900a3a1042fef755d8fdc6d8bf Mon Sep 17 00:00:00 2001 From: zsviczian Date: Sat, 17 Sep 2022 20:21:27 +0200 Subject: [PATCH] fix: double state update incorrectly resetting state (#5704) Co-authored-by: David Luzar --- src/components/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 2e8d8cb3..06115155 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1153,7 +1153,11 @@ class App extends React.Component { ) { // defer so that the commitToHistory flag isn't reset via current update setTimeout(() => { - this.actionManager.executeAction(actionFinalize); + // execute only if the condition still holds when the deferred callback + // executes (it can be scheduled multiple times depending on how + // many times the component renders) + this.state.editingLinearElement && + this.actionManager.executeAction(actionFinalize); }); }