diff --git a/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-library.spec.ts-snapshots/Open-Ketcher-Open-Chem-tab-in-library-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-library.spec.ts-snapshots/Open-Ketcher-Open-Chem-tab-in-library-1-chromium-linux.png index c6651c76c8..f93e952d86 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-library.spec.ts-snapshots/Open-Ketcher-Open-Chem-tab-in-library-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-library.spec.ts-snapshots/Open-Ketcher-Open-Chem-tab-in-library-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Make-full-screen-mode-in-micro-mode-and-switch-to-macro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Make-full-screen-mode-in-micro-mode-and-switch-to-macro-mode-1-chromium-linux.png index f9ee1e50d7..e82a2e01c8 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Make-full-screen-mode-in-micro-mode-and-switch-to-macro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Make-full-screen-mode-in-micro-mode-and-switch-to-macro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Monomer-library-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Monomer-library-1-chromium-linux.png index fff0ed3ee3..14d904bb7e 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Monomer-library-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Monomer-library-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Placing-betaAlanine-on-canvas-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Placing-betaAlanine-on-canvas-1-chromium-linux.png index 018e7163df..fbd65a93a0 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Placing-betaAlanine-on-canvas-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Placing-betaAlanine-on-canvas-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Structure-displaying-in-library-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Structure-displaying-in-library-1-chromium-linux.png index 44dab5170f..feea644366 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Structure-displaying-in-library-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-Structure-displaying-in-library-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-add-molecule-in-favourites-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-add-molecule-in-favourites-1-chromium-linux.png index 1f27769d03..142742b124 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-add-molecule-in-favourites-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts-snapshots/Peptide-library-testing-add-molecule-in-favourites-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/connect-phosphate-and-sugar.spec.ts-snapshots/Macromolecules-connect-phosphate-and-sugar-Open-file-and-connect-phosphate-and-sugar-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/connect-phosphate-and-sugar.spec.ts-snapshots/Macromolecules-connect-phosphate-and-sugar-Open-file-and-connect-phosphate-and-sugar-1-chromium-linux.png index ef4f9c70b0..ce7e4a343d 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/connect-phosphate-and-sugar.spec.ts-snapshots/Macromolecules-connect-phosphate-and-sugar-Open-file-and-connect-phosphate-and-sugar-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/connect-phosphate-and-sugar.spec.ts-snapshots/Macromolecules-connect-phosphate-and-sugar-Open-file-and-connect-phosphate-and-sugar-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Bases-component-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Bases-component-1-chromium-linux.png index 15ba184097..f97c177cf2 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Bases-component-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Bases-component-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Phosphates-component-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Phosphates-component-1-chromium-linux.png index 449d3f8260..714b121dbe 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Phosphates-component-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Phosphates-component-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Sugars-component-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Sugars-component-1-chromium-linux.png index 082052ae13..a2e7b2c70f 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Sugars-component-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Check-Sugars-component-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Highlight-Sugar-Phosphate-and-Base-in-Library-once-it-chosen-in-RNA-Builder-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Highlight-Sugar-Phosphate-and-Base-in-Library-once-it-chosen-in-RNA-Builder-1-chromium-linux.png index cafd81ca68..36c09b42c7 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Highlight-Sugar-Phosphate-and-Base-in-Library-once-it-chosen-in-RNA-Builder-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/rna-library.spec.ts-snapshots/RNA-Library-Highlight-Sugar-Phosphate-and-Base-in-Library-once-it-chosen-in-RNA-Builder-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Modify-nucleotides-from-sequence-in-RNA-builde-77b62-as-no-R2-or-R3-it-is-disabled-in-RNA-Builder-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Modify-nucleotides-from-sequence-in-RNA-builde-77b62-as-no-R2-or-R3-it-is-disabled-in-RNA-Builder-1-chromium-linux.png index 579f89cef6..66b06f8d66 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Modify-nucleotides-from-sequence-in-RNA-builde-77b62-as-no-R2-or-R3-it-is-disabled-in-RNA-Builder-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Modify-nucleotides-from-sequence-in-RNA-builde-77b62-as-no-R2-or-R3-it-is-disabled-in-RNA-Builder-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Sequence-mode-edit-in-RNA-Builder-Select-one-nucleotide-and-modify-sugar-3-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Sequence-mode-edit-in-RNA-Builder-Select-one-nucleotide-and-modify-sugar-3-chromium-linux.png index 111f4bcb43..9f11429337 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Sequence-mode-edit-in-RNA-Builder-Select-one-nucleotide-and-modify-sugar-3-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit-in-rna-builder.spec.ts-snapshots/Sequence-mode-edit-in-RNA-Builder-Select-one-nucleotide-and-modify-sugar-3-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit.spec.ts-snapshots/Sequence-edit-mode-Text-editing-mode-activates-8b4e6--start-a-new-sequence-or-edit-an-existing-one-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit.spec.ts-snapshots/Sequence-edit-mode-Text-editing-mode-activates-8b4e6--start-a-new-sequence-or-edit-an-existing-one-1-chromium-linux.png index e66632a20d..fca28f9528 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit.spec.ts-snapshots/Sequence-edit-mode-Text-editing-mode-activates-8b4e6--start-a-new-sequence-or-edit-an-existing-one-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-edit.spec.ts-snapshots/Sequence-edit-mode-Text-editing-mode-activates-8b4e6--start-a-new-sequence-or-edit-an-existing-one-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode.spec.ts-snapshots/Sequence-Mode-Select-drop-down-menu-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode.spec.ts-snapshots/Sequence-Mode-Select-drop-down-menu-1-chromium-linux.png index 190485fa04..2e9bd54775 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode.spec.ts-snapshots/Sequence-Mode-Select-drop-down-menu-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode.spec.ts-snapshots/Sequence-Mode-Select-drop-down-menu-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Zoom-Tool/zoom.spec.ts-snapshots/Zoom-Tool-Maximum-browser-zoom-out-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Zoom-Tool/zoom.spec.ts-snapshots/Zoom-Tool-Maximum-browser-zoom-out-1-chromium-linux.png index e86d5be87e..e309f2bc47 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Zoom-Tool/zoom.spec.ts-snapshots/Zoom-Tool-Maximum-browser-zoom-out-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Zoom-Tool/zoom.spec.ts-snapshots/Zoom-Tool-Maximum-browser-zoom-out-1-chromium-linux.png differ diff --git a/packages/ketcher-macromolecules/src/state/library/librarySlice.ts b/packages/ketcher-macromolecules/src/state/library/librarySlice.ts index ddee42bc1e..e4a40fbcb5 100644 --- a/packages/ketcher-macromolecules/src/state/library/librarySlice.ts +++ b/packages/ketcher-macromolecules/src/state/library/librarySlice.ts @@ -179,28 +179,50 @@ export const selectMonomers = (state: RootState) => { }; export const selectMonomerGroups = (monomers: MonomerItemType[]) => { - const preparedData = monomers.reduce((result, monomerItem) => { - // separate monomers by NaturalAnalogCode - const code = monomerItem.props.MonomerNaturalAnalogCode; - if (!result[code]) { - result[code] = []; - } - result[code].push({ - ...monomerItem, - label: monomerItem.props.MonomerName, - }); - return result; - }, {}); + const preparedData: Record = monomers.reduce( + (result, monomerItem) => { + // separate monomers by NaturalAnalogCode + const code = monomerItem.props.MonomerNaturalAnalogCode; + if (!result[code]) { + result[code] = []; + } + result[code].push({ + ...monomerItem, + label: monomerItem.props.MonomerName, + }); + return result; + }, + {}, + ); + + const sortedPreparedData = Object.entries(preparedData).reduce( + (result, [code, monomers]) => { + const sortedMonomers = monomers.sort((a, b) => + a.label.localeCompare(b.label), + ); + const baseIndex = sortedMonomers.findIndex( + (monomer) => monomer.label === code, + ); + if (baseIndex !== -1) { + const base = sortedMonomers.splice(baseIndex, 1); + sortedMonomers.unshift(base[0]); + } + result[code] = sortedMonomers; + return result; + }, + {}, + ); + // generate list of monomer groups const preparedGroups: Group[] = []; - return Object.keys(preparedData) + return Object.keys(sortedPreparedData) .sort() .reduce((result, code) => { const group: Group = { groupTitle: code, groupItems: [], }; - preparedData[code].forEach((item: MonomerItemType) => { + sortedPreparedData[code].forEach((item: MonomerItemType) => { group.groupItems.push({ ...item, props: { ...item.props },