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 29989d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ test.describe('Plus and Arrows tools ', () => {
page,
}) => {
await copyAndPaste(page);
await page.mouse.move(point.x - 100, point.y - 100);
await page.mouse.click(point.x - 100, point.y - 100);
await takeEditorScreenshot(page);
await selectTopPanelButton(TopPanelButton.Undo, page);
await takeEditorScreenshot(page);
Expand Down Expand Up @@ -305,7 +305,7 @@ test.describe('Plus and Arrows tools ', () => {
page,
}) => {
await copyAndPaste(page);
await page.mouse.move(point.x - 100, point.y - 100);
await page.mouse.click(point.x - 100, point.y - 100);
await takeEditorScreenshot(page);
await selectTopPanelButton(TopPanelButton.Undo, page);
await takeEditorScreenshot(page);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 29989d6

Please sign in to comment.