Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro: #3539 – When pull bond away from monomer and press 'Escape', bond remains on canvas #3556

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -272,7 +276,9 @@ class PolymerBond implements BaseTool {
this.bondRenderer = undefined;
};

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

private shouldInvokeModal(
firstMonomer: BaseMonomer,
Expand Down
Loading