diff --git a/packages/ketcher-core/src/application/render/renderers/sequence/SequenceRenderer.ts b/packages/ketcher-core/src/application/render/renderers/sequence/SequenceRenderer.ts index 58c0ef56a7..e8d3fbadb9 100644 --- a/packages/ketcher-core/src/application/render/renderers/sequence/SequenceRenderer.ts +++ b/packages/ketcher-core/src/application/render/renderers/sequence/SequenceRenderer.ts @@ -218,7 +218,7 @@ export class SequenceRenderer { const bondRenderer = new PolymerBondSequenceRenderer( polymerBond, chain.firstNode, - chain.lastNode, + chain.lastNonEmptyNode, ); bondRenderer.show(); polymerBond.setRenderer(bondRenderer); diff --git a/packages/ketcher-core/src/domain/entities/monomer-chains/Chain.ts b/packages/ketcher-core/src/domain/entities/monomer-chains/Chain.ts index 143490ba5a..8058ccae23 100644 --- a/packages/ketcher-core/src/domain/entities/monomer-chains/Chain.ts +++ b/packages/ketcher-core/src/domain/entities/monomer-chains/Chain.ts @@ -95,10 +95,29 @@ export class Chain { return this.subChains[this.subChains.length - 1]; } + public get nodes() { + const nodes: SubChainNode[] = []; + this.subChains.forEach((subChain) => { + nodes.push(...subChain.nodes); + }); + + return nodes; + } + public get lastNode() { return this.lastSubChain?.lastNode; } + public get lastNonEmptyNode() { + if (this.lastNode instanceof EmptySequenceNode) { + const nodes = this.nodes; + + return nodes[nodes.length - 2]; + } else { + return this.lastNode; + } + } + public get firstSubChain() { return this.subChains[0]; }