Skip to content

Commit

Permalink
#3005 - Unable to 'undo' the paste action, if there is no reset to Se…
Browse files Browse the repository at this point in the history
…lect tool
  • Loading branch information
ilya-asiyuk-epam committed Feb 27, 2024
1 parent 9e7af50 commit ab96b27
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,17 +538,18 @@ class Editor implements KetcherEditor {

this.selection(null);

if (this._tool instanceof toolsMap.paste) {
this.event.change.dispatch();
return;
}

this.historyPtr--;
const stack = this.historyStack[this.historyPtr];
const action = stack.perform(this.render.ctab);

this.historyStack[this.historyPtr] = action;
this.event.change.dispatch(action);

if (this._tool instanceof toolsMap.paste) {
this.event.change.dispatch();
} else {
this.event.change.dispatch(action);
}

this.render.update();
}

Expand All @@ -562,15 +563,17 @@ class Editor implements KetcherEditor {
}

this.selection(null);
if (this._tool instanceof toolsMap.paste) {
this.event.change.dispatch();
return;
}

const action = this.historyStack[this.historyPtr].perform(this.render.ctab);
this.historyStack[this.historyPtr] = action;
this.historyPtr++;
this.event.change.dispatch(action);

if (this._tool instanceof toolsMap.paste) {
this.event.change.dispatch();
} else {
this.event.change.dispatch(action);
}

this.render.update();
}

Expand Down

0 comments on commit ab96b27

Please sign in to comment.