diff --git a/packages/ketcher-core/src/application/editor/Editor.ts b/packages/ketcher-core/src/application/editor/Editor.ts index 1f3d3418b4..af9b542269 100644 --- a/packages/ketcher-core/src/application/editor/Editor.ts +++ b/packages/ketcher-core/src/application/editor/Editor.ts @@ -82,8 +82,7 @@ export class CoreEditor { // todo we need to create abstraction layer for modes in future similar to the tools layer private onSelectMode(isSnakeMode: boolean) { PolymerBondRenderer.setSnakeMode(isSnakeMode); - let modelChanges; - modelChanges = this.drawingEntitiesManager.reArrangeChain( + const modelChanges = this.drawingEntitiesManager.reArrangeChain( this.canvas.width.baseVal.value, isSnakeMode, ); diff --git a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts index 5e26896f21..9e5d8c420f 100644 --- a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts +++ b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts @@ -509,7 +509,7 @@ export class DrawingEntitiesManager { chain[i - 1].position, editorSettings, ); - let isMonomerFitCanvas = + const isMonomerFitCanvas = prevPosition.x + DISTANCE_BETWEEN_MONOMERS + initCoords.x + @@ -556,14 +556,15 @@ export class DrawingEntitiesManager { private findChainByMonomer(monomer: BaseMonomer) { let firstMonomer = monomer; while (this.getPrevMonomer(firstMonomer)) { - firstMonomer = this.getPrevMonomer(firstMonomer)!; + firstMonomer = this.getPrevMonomer(firstMonomer) ?? firstMonomer; } const monomerChain = [] as BaseMonomer[]; let monomerInTheChain = firstMonomer; monomerChain.push(monomerInTheChain); while (this.getNextMonomer(monomerInTheChain)) { - monomerInTheChain = this.getNextMonomer(monomerInTheChain)!; + monomerInTheChain = + this.getNextMonomer(monomerInTheChain) ?? firstMonomer; monomerChain.push(monomerInTheChain); } return monomerChain;