Skip to content

Commit

Permalink
#5255 – Fix adding new monomers to canvas in sequence mode while edit…
Browse files Browse the repository at this point in the history
…ing RNA in builder
  • Loading branch information
svvald committed Aug 8, 2024
1 parent 5e94631 commit e73f342
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -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 e73f342

Please sign in to comment.