From 73458577ecce7ab702886e33c8761451589fc19b Mon Sep 17 00:00:00 2001 From: guchigow Date: Fri, 7 Jun 2024 03:01:56 +0500 Subject: [PATCH 1/2] #4636 - In the Sequence mode, when selecting elements on the canvas, the total number of elements is not displayed in the Right-click menu --- .../contextMenu/SequenceItemContextMenu/helpers.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts b/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts index f3d9f45b86..c57fcc8280 100644 --- a/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts +++ b/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts @@ -120,9 +120,10 @@ export const generateSequenceContextMenuProps = ( ) { title = generateNucleoelementTitle(selectedSequenceLabeledNodes); } else { - title = isSelectedOnlyNucleoelements - ? `${countOfNucleoelements} nucleotides` - : `${countOfSelections} elements`; + title = + countOfSelections === countOfNucleoelements + ? `${countOfNucleoelements} nucleotides` + : `${countOfSelections} elements`; } return { From e7cdd3994a851a346c290183fa01ed2cd4df1559 Mon Sep 17 00:00:00 2001 From: guchigow Date: Fri, 7 Jun 2024 11:30:24 +0500 Subject: [PATCH 2/2] Hotfix: add isNucleotideNucleosideOrPhosphate function --- .../SequenceItemContextMenu/helpers.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts b/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts index c57fcc8280..2f417516c2 100644 --- a/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts +++ b/packages/ketcher-macromolecules/src/components/contextMenu/SequenceItemContextMenu/helpers.ts @@ -53,6 +53,15 @@ const generateLabeledNodes = ( return labeledNodes; }; +function isNucleotideNucleosideOrPhosphate(selection: NodeSelection): boolean { + const { node } = selection; + return ( + node instanceof Nucleotide || + node instanceof Nucleoside || + node?.monomer instanceof Phosphate + ); +} + // Generate menu title if selected: // one nucleotide // one nucleoside @@ -112,6 +121,11 @@ export const generateSequenceContextMenuProps = ( isSelectedOnlyNucleoelements = false; } } + if (countOfSelections > countOfNucleoelements) { + if (!selectionsFlatten.every(isNucleotideNucleosideOrPhosphate)) { + isSelectedOnlyNucleoelements = false; + } + } // Set title based on selected elements if ( @@ -120,10 +134,9 @@ export const generateSequenceContextMenuProps = ( ) { title = generateNucleoelementTitle(selectedSequenceLabeledNodes); } else { - title = - countOfSelections === countOfNucleoelements - ? `${countOfNucleoelements} nucleotides` - : `${countOfSelections} elements`; + title = isSelectedOnlyNucleoelements + ? `${countOfNucleoelements} nucleotides` + : `${countOfSelections} elements`; } return {