Skip to content

Commit

Permalink
#4548 - Cyclic chains disappear from canvas when try to Edit in the s…
Browse files Browse the repository at this point in the history
…equence mode (#4609)

- used lastNonEmptyNode instead of lastNode for cyclic chain end bond render

Co-authored-by: Dmitry Baranov <baranov.d.v.1988@gmail.com>
  • Loading branch information
rrodionov91 and baranovdv authored May 13, 2024
1 parent 5f3688e commit bb5239a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class SequenceRenderer {
const bondRenderer = new PolymerBondSequenceRenderer(
polymerBond,
chain.firstNode,
chain.lastNode,
chain.lastNonEmptyNode,
);
bondRenderer.show();
polymerBond.setRenderer(bondRenderer);
Expand Down
19 changes: 19 additions & 0 deletions packages/ketcher-core/src/domain/entities/monomer-chains/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit bb5239a

Please sign in to comment.