Skip to content

Commit

Permalink
Merge pull request #3166 from epam/3128-when-dragging-and-dropping-a-…
Browse files Browse the repository at this point in the history
…functional-group-onto-the-structure-numerous-errors-appear-in-the-console

#3128 - When dragging and dropping a Functional Group onto the structure, numerous errors appear in the console
  • Loading branch information
rrodionov91 authored Aug 22, 2023
2 parents bbecd5a + fe5b1a6 commit 614d894
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,16 @@ export class SGroup {
* WHY? When group is contracted we need to understand the represent atom to calculate position.
* It is not always the attachmentPoint!! if no attachment point - use the first atom
*/
getContractedPosition(struct: Struct): { atomId: number; position: Vec2 } {
const atomId = this.attachmentPoints[0]?.atomId ?? this.atoms[0];
const representAtom = struct.atoms.get(atomId);
getContractedPosition(struct: Struct): {
atomId: number;
position: Vec2;
} {
let atomId = this.attachmentPoints[0]?.atomId;
let representAtom = struct.atoms.get(atomId);
if (!representAtom) {
atomId = this.atoms[0];
representAtom = struct.atoms.get(this.atoms[0]);
}
assert(representAtom != null);
return { atomId, position: representAtom.pp };
}
Expand Down

0 comments on commit 614d894

Please sign in to comment.