From dd41632017bee6ce1da701ad3566f1864306ea40 Mon Sep 17 00:00:00 2001 From: Roman Rodionov Date: Wed, 4 Dec 2024 19:27:36 +0100 Subject: [PATCH] #5969 - Load from file having only micro structures on macro canvas causes unnecessary zoom up to 200% and shift molecule to top left angle (#6057) --- packages/ketcher-core/src/application/editor/Editor.ts | 3 ++- .../src/domain/entities/DrawingEntitiesManager.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/ketcher-core/src/application/editor/Editor.ts b/packages/ketcher-core/src/application/editor/Editor.ts index f52af58dd2..4cb5e5c981 100644 --- a/packages/ketcher-core/src/application/editor/Editor.ts +++ b/packages/ketcher-core/src/application/editor/Editor.ts @@ -648,7 +648,8 @@ export class CoreEditor { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore window._ketcher_isAutozoomDisabled || - !this.isCurrentModeWithAutozoom() + !this.isCurrentModeWithAutozoom() || + !this.drawingEntitiesManager.hasMonomers ) { return; } diff --git a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts index 83418cbaf1..533316feb0 100644 --- a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts +++ b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts @@ -166,6 +166,16 @@ export class DrawingEntitiesManager { return this.allEntities.length !== 0; } + public get hasMonomers() { + const monomers = [...this.monomers.values()].filter( + (monomer) => + !monomer.monomerItem.props.isMicromoleculeFragment || + isMonomerSgroupWithAttachmentPoints(monomer), + ); + + return monomers.length !== 0; + } + public get allBondsToMonomers() { return [ ...(this.polymerBonds as Map),