Skip to content

Commit

Permalink
Macro: #3539 – When pull bond away from monomer and press 'Escape', b…
Browse files Browse the repository at this point in the history
…ond remains on canvas (#3556)

* Correct handling escape key when drawing a bond
  • Loading branch information
ivan-arkhipov-epam authored Nov 9, 2023
1 parent cb2738b commit 7150de2
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/ketcher-core/src/application/editor/tools/Bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ class PolymerBond implements BaseTool {
this.editor = editor;
}

private removeBond(): void {
if (this.bondRenderer) {
const modelChanges =
this.editor.drawingEntitiesManager.cancelPolymerBondCreation(
this.bondRenderer.polymerBond,
);
this.editor.renderersContainer.update(modelChanges);
this.bondRenderer = undefined;
}
}

public mousedown(event) {
const selectedRenderer = event.target.__data__;
if (selectedRenderer instanceof BaseMonomerRenderer) {
Expand Down Expand Up @@ -159,14 +170,7 @@ class PolymerBond implements BaseTool {
if (this.isBondConnectionModalOpen) {
return;
}
if (this.bondRenderer) {
const modelChanges =
this.editor.drawingEntitiesManager.cancelPolymerBondCreation(
this.bondRenderer.polymerBond,
);
this.editor.renderersContainer.update(modelChanges);
this.bondRenderer = undefined;
}
this.removeBond();
}

public mouseUpMonomer(event) {
Expand Down Expand Up @@ -258,7 +262,9 @@ class PolymerBond implements BaseTool {
this.bondRenderer = undefined;
};

public destroy() {}
public destroy() {
this.removeBond();
}

private shouldInvokeModal(
firstMonomer: BaseMonomer,
Expand Down

0 comments on commit 7150de2

Please sign in to comment.