Skip to content

Commit

Permalink
Merge pull request #41 from uncountableinc/david/drag-s-group
Browse files Browse the repository at this point in the history
only drag s group if not selected
  • Loading branch information
martinuncountable authored Feb 27, 2025
2 parents f6ca49e + 126965e commit 2dbf708
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/ketcher-react/src/script/editor/tool/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ class SelectTool implements Tool {
if (isBondingWithMacroMolecule(this.editor, event)) {
return;
}

const selected = {
...(ci?.map === 'atoms' && { atoms: [ci.id] }),
...(ci?.map === 'bonds' && { bonds: [ci.id] }),
};
const selectedSgroups = ci
? getGroupIdsFromItemArrays(molecule, selected)
: [];
const newSelected = getNewSelectedItems(this.editor, selectedSgroups);
if (newSelected.atoms?.length || newSelected.bonds?.length) {
this.editor.selection(newSelected);
let selection = this.editor.selection();
if (ci != null && !isSelected(selection, ci)) {
const selected = {
...(ci?.map === 'atoms' && { atoms: [ci.id] }),
...(ci?.map === 'bonds' && { bonds: [ci.id] }),
};
const selectedSgroups = ci
? getGroupIdsFromItemArrays(molecule, selected)
: [];
const newSelected = getNewSelectedItems(this.editor, selectedSgroups);
if (newSelected.atoms?.length || newSelected.bonds?.length) {
this.editor.selection(newSelected);
}
}

this.dragCtx = {
Expand All @@ -134,7 +136,7 @@ class SelectTool implements Tool {

let sel = closestToSel(ci);
const sgroups = ctab.sgroups.get(ci.id);
const selection = this.editor.selection();
selection = this.editor.selection();
if (ci.map === 'frags') {
const frag = ctab.frags.get(ci.id);
sel = {
Expand Down

0 comments on commit 2dbf708

Please sign in to comment.