Skip to content

Commit 8d148c7

Browse files
committed
fixed commonly observed bug of duplicates reapplying after undo
1 parent 542403b commit 8d148c7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/canvas/Canvas.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,20 @@ class Canvas extends React.Component {
198198
}
199199

200200
modifyCanvas(nameOfFunction, finishedCb) {
201-
// before we modify the canvas, let's save the current state
202201
let { steps, changeHistory } = this.state;
203202
changeHistory = changeHistory.slice()
204203
changeHistory.push({ steps: Array.from(steps) });
205204
// okay, now we call the requested function from Toolbox
206205
this.setState({ finishCB: finishedCb }, () => {
207206
this.state.functions[nameOfFunction]().then(state => {
207+
// before we modify the canvas, let's save the current state
208208
if (this.state.finishCB) {
209209
this.state.finishCB();
210210
}
211211
if (state) {
212212
// now we can apply the new changeHistory
213213
this.setState({
214-
changeHistory: changeHistory,
214+
changeHistory,
215215
redoHistory: [],
216216
...state }, () => {
217217
this.checkLevelIntegrity();
@@ -546,6 +546,7 @@ class Canvas extends React.Component {
546546
setStep={s => this.setState({ currentStep: s, interaction: s === this.state.steps.length - 1 })}
547547
state={this.state}
548548
setState={(changeHistory, newSteps, redoHistory) => {
549+
this.cancelSelection();
549550
this.setState({
550551
changeHistory: changeHistory,
551552
steps: newSteps,

0 commit comments

Comments
 (0)