Skip to content

Commit

Permalink
Backmerge: #5809 – Open correct context menu for expanded monomer whi…
Browse files Browse the repository at this point in the history
…le clicking on bond or atom (#5901)
  • Loading branch information
svvald authored Nov 4, 2024
1 parent 909baef commit a691731
Showing 1 changed file with 44 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,28 @@ export function getMenuPropsForClosestItem(
true,
);

return functionalGroup === null ||
functionalGroup?.relatedSGroup.isSuperatomWithoutLabel
? {
id: CONTEXT_MENU_ID.FOR_BONDS,
bondIds: [closestItem.id],
}
: {
id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
functionalGroups: [functionalGroup],
};
const noFunctionalGroup =
functionalGroup === null ||
functionalGroup?.relatedSGroup.isSuperatomWithoutLabel;
const isMonomer =
functionalGroup?.relatedSGroup instanceof MonomerMicromolecule;

if (noFunctionalGroup) {
return {
id: CONTEXT_MENU_ID.FOR_BONDS,
bondIds: [closestItem.id],
};
} else if (isMonomer) {
return {
id: CONTEXT_MENU_ID.FOR_MACROMOLECULE,
functionalGroups: [functionalGroup],
};
} else {
return {
id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
functionalGroups: [functionalGroup],
};
}
}

case 'atoms': {
Expand All @@ -73,16 +85,28 @@ export function getMenuPropsForClosestItem(
true,
);

return functionalGroup === null ||
functionalGroup?.relatedSGroup.isSuperatomWithoutLabel
? {
id: CONTEXT_MENU_ID.FOR_ATOMS,
atomIds: [closestItem.id],
}
: {
id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
functionalGroups: [functionalGroup],
};
const noFunctionalGroup =
functionalGroup === null ||
functionalGroup?.relatedSGroup.isSuperatomWithoutLabel;
const isMonomer =
functionalGroup?.relatedSGroup instanceof MonomerMicromolecule;

if (noFunctionalGroup) {
return {
id: CONTEXT_MENU_ID.FOR_ATOMS,
atomIds: [closestItem.id],
};
} else if (isMonomer) {
return {
id: CONTEXT_MENU_ID.FOR_MACROMOLECULE,
functionalGroups: [functionalGroup],
};
} else {
return {
id: CONTEXT_MENU_ID.FOR_FUNCTIONAL_GROUPS,
functionalGroups: [functionalGroup],
};
}
}

case 'sgroups':
Expand Down

0 comments on commit a691731

Please sign in to comment.