Skip to content

Commit

Permalink
Backmerge: #5255 – Fix adding new monomers to canvas in sequence mode…
Browse files Browse the repository at this point in the history
… while editing RNA in builder (#5260)
  • Loading branch information
svvald authored and Guch1g0v committed Oct 17, 2024
1 parent 3f2d3d5 commit 8e55feb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ export const RnaAccordion = ({ libraryName, duplicatePreset, editPreset }) => {
];

const selectItem = (monomer, groupName) => {
if (!isSequenceEditInRNABuilderMode) {
if (!isSequenceEditInRNABuilderMode && !isEditMode) {
editor.events.selectMonomer.dispatch(monomer);
}
if (!isEditMode) return;

if (!isEditMode) {
return;
}

const monomerClass = monomer.props.MonomerClass.toLowerCase();
const currentPreset = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { fireEvent, render, screen } from '@testing-library/react';
import { RnaEditorExpanded } from 'components/monomerLibrary/RnaBuilder/RnaEditor/RnaEditorExpanded/RnaEditorExpanded';
import { EmptyFunction } from 'helpers';

jest.mock('hooks', () => ({
...jest.requireActual('hooks'),
useLayoutMode: () => 'sequence-layout-mode',
}));

describe('Test Rna Editor Expanded component', () => {
it('should render correctly in edit mode', async () => {
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
***************************************************************************/

import { Entities } from 'ketcher-core';
import { Entities, ModeTypes } from 'ketcher-core';
import { MonomerGroups } from 'src/constants';
import { GroupBlock } from './GroupBlock';
import {
Expand Down Expand Up @@ -53,7 +53,7 @@ import {
setSequenceSelectionName,
selectIsActivePresetNewAndEmpty,
} from 'state/rna-builder';
import { useAppSelector } from 'hooks';
import { useAppSelector, useLayoutMode } from 'hooks';
import {
scrollToSelectedMonomer,
scrollToSelectedPreset,
Expand Down Expand Up @@ -126,6 +126,8 @@ export const RnaEditorExpanded = ({
generateSequenceSelectionGroupNames(sequenceSelection),
);

const isSequenceMode = useLayoutMode() === ModeTypes.sequence;

const updatePresetMonomerGroup = () => {
if (activePresetMonomerGroup) {
const groupName =
Expand Down Expand Up @@ -216,7 +218,7 @@ export const RnaEditorExpanded = ({
selectedGroup,
);

if (selectedRNAPartMonomer) {
if (selectedRNAPartMonomer && !isSequenceMode) {
editor.events.selectMonomer.dispatch(selectedRNAPartMonomer);
}
scrollToActiveItemInLibrary(selectedGroup);
Expand Down

0 comments on commit 8e55feb

Please sign in to comment.