Skip to content

Commit

Permalink
#3918 - When deleting part of a structure using a hotkey Del, and pre…
Browse files Browse the repository at this point in the history
…view of structure is under mouse cursor, an error occurs.

- added template connected preview hiding before erase by hotkey
  • Loading branch information
rrodionov91 committed Feb 23, 2024
1 parent 5395b1d commit 572990f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TemplateTool implements Tool {
private readonly mode: any;
private readonly template: any;
private readonly findItems: Array<string>;
private templatePreview: TemplatePreview | null;
public templatePreview: TemplatePreview | null;
private dragCtx: any;
private targetGroupsIds: Array<number> = [];
private readonly isSaltOrSolvent: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class TemplatePreview {
}
}

private hideConnectedPreview() {
public hideConnectedPreview() {
if (this.connectedPreviewAction) {
this.connectedPreviewAction.perform(this.restruct);
this.connectedPreviewAction = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { updateSelectedAtoms } from 'src/script/ui/state/modal/atoms';
import { fromAtom, toAtom, fromBond, toBond } from '../data/convert/structconv';
import SGroupTool from '../../editor/tool/sgroup';
import { deleteFunctionalGroups } from '../../editor/tool/helper/deleteFunctionalGroups';
import TemplateTool from '../../editor/tool/template';

type TNewAction = {
tool?: string;
Expand Down Expand Up @@ -80,6 +81,11 @@ function handleEraser({
}: HandleHotkeyOverItemProps) {
const item = mapItemsToArrays(hoveredItem);
const itemType = Object.keys(hoveredItem)[0];
const activeTool = editor.tool();

if (activeTool instanceof TemplateTool) {
activeTool.templatePreview?.hideConnectedPreview();
}

if ([STRUCT_TYPE.atoms, STRUCT_TYPE.bonds].includes(itemType)) {
isFunctionalGroupChange(
Expand All @@ -88,11 +94,9 @@ function handleEraser({
).then((res) => {
res && eraseItem({ editor, item });
});

return;
} else {
eraseItem({ editor, item });
}

eraseItem({ editor, item });
}

function handleDialog({
Expand Down

0 comments on commit 572990f

Please sign in to comment.