diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-macromolecule--716dd-romode-are-represented-as-S-Groups-with-bonds-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-macromolecule--716dd-romode-are-represented-as-S-Groups-with-bonds-1-chromium-linux.png
index ccff6560da..fda8ccc2c2 100755
Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-macromolecule--716dd-romode-are-represented-as-S-Groups-with-bonds-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-macromolecule--716dd-romode-are-represented-as-S-Groups-with-bonds-1-chromium-linux.png differ
diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Verify-that-Expand-monomer-does-not-break-cyclic-structures-when-the-ring-is-expanded-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Verify-that-Expand-monomer-does-not-break-cyclic-structures-when-the-ring-is-expanded-2-chromium-linux.png
index 5f0ddba257..2be00a360b 100644
Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Verify-that-Expand-monomer-does-not-break-cyclic-structures-when-the-ring-is-expanded-2-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Verify-that-Expand-monomer-does-not-break-cyclic-structures-when-the-ring-is-expanded-2-chromium-linux.png differ
diff --git a/packages/ketcher-core/src/application/editor/actions/sgroup.ts b/packages/ketcher-core/src/application/editor/actions/sgroup.ts
index 3ad7c632ee..0873f95c11 100644
--- a/packages/ketcher-core/src/application/editor/actions/sgroup.ts
+++ b/packages/ketcher-core/src/application/editor/actions/sgroup.ts
@@ -196,7 +196,10 @@ export function setExpandMonomerSGroup(
atom.a.neighbors.forEach((halfBondId) => {
const neighborAtomId =
restruct.molecule?.halfBonds?.get(halfBondId)?.end;
- if (!neighborAtomId || sGroupAtoms.includes(neighborAtomId)) {
+ if (
+ neighborAtomId === undefined ||
+ sGroupAtoms.includes(neighborAtomId)
+ ) {
return;
}
diff --git a/packages/ketcher-core/src/domain/entities/monomerMicromolecule.ts b/packages/ketcher-core/src/domain/entities/monomerMicromolecule.ts
index 81bd9be656..5b96850d2a 100644
--- a/packages/ketcher-core/src/domain/entities/monomerMicromolecule.ts
+++ b/packages/ketcher-core/src/domain/entities/monomerMicromolecule.ts
@@ -24,6 +24,10 @@ export class MonomerMicromolecule extends SGroup {
this.data.attached = false;
}
+ public get isMonomer() {
+ return true;
+ }
+
public override getContractedPosition(struct: Struct) {
assert(this.pp);
const sgroupContractedPosition = super.getContractedPosition(struct);
diff --git a/packages/ketcher-core/src/domain/entities/sgroup.ts b/packages/ketcher-core/src/domain/entities/sgroup.ts
index b04ff05186..0ae471608e 100644
--- a/packages/ketcher-core/src/domain/entities/sgroup.ts
+++ b/packages/ketcher-core/src/domain/entities/sgroup.ts
@@ -368,6 +368,10 @@ export class SGroup {
return this.type === SGroup.TYPES.SUP && !this.data.name;
}
+ public get isMonomer() {
+ return false;
+ }
+
static getOffset(sgroup: SGroup): null | Vec2 {
if (!sgroup?.pp || !sgroup.bracketBox) return null;
return Vec2.diff(sgroup.pp, sgroup.bracketBox.p1);
@@ -504,7 +508,8 @@ export class SGroup {
const crossBonds = crossBondsPerAtom
? Object.values(crossBondsPerAtom).flat()
: null;
- if (!crossBonds || crossBonds.length !== 2) {
+ // TODO: Overall cross bonds logic seems unclear and not-correct for s groups in general leading to tilted hover plate
+ if (sGroup.isMonomer || !crossBonds || crossBonds.length !== 2) {
sGroup.bracketDirection = new Vec2(1, 0);
} else {
const p1 = mol.bonds.get(crossBonds[0]).getCenter(mol);
diff --git a/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/MacromoleculeMenuItems.tsx b/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/MacromoleculeMenuItems.tsx
index dd70e11923..6a70b06866 100644
--- a/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/MacromoleculeMenuItems.tsx
+++ b/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/MacromoleculeMenuItems.tsx
@@ -10,6 +10,17 @@ const MacromoleculeMenuItems = (
) => {
const [action, hidden] = useMonomerExpansionHandlers();
+ const multipleMonomersSelected =
+ props?.propsFromTrigger?.functionalGroups &&
+ props.propsFromTrigger.functionalGroups.length > 1;
+
+ const expandText = multipleMonomersSelected
+ ? 'Expand monomers'
+ : 'Expand monomer';
+ const collapseText = multipleMonomersSelected
+ ? 'Collapse monomers'
+ : 'Collapse monomer';
+
return (
<>
- hidden(params, true)}
onClick={(params) => action(params, true)}
>
- Expand monomer
+ {expandText}
- hidden(params, false)}
onClick={(params) => action(params, false)}
>
- Collapse monomer
+ {collapseText}
>
);