diff --git a/packages/ketcher-core/src/application/editor/tools/Bond.ts b/packages/ketcher-core/src/application/editor/tools/Bond.ts index 974d786537..0f81693a7b 100644 --- a/packages/ketcher-core/src/application/editor/tools/Bond.ts +++ b/packages/ketcher-core/src/application/editor/tools/Bond.ts @@ -36,6 +36,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) { @@ -173,14 +184,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) { @@ -272,7 +276,9 @@ class PolymerBond implements BaseTool { this.bondRenderer = undefined; }; - public destroy() {} + public destroy() { + this.removeBond(); + } private shouldInvokeModal( firstMonomer: BaseMonomer,