Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File #6370

Closed
Tracked by #6600
Zhirnoff opened this issue Jan 28, 2025 · 1 comment · Fixed by #6373 or #6376
Assignees
Labels
API Common UI problems Bucket: Common UI problems Priority: High Severity: Low Low level visibility to the user User`s Feedback

Comments

@Zhirnoff
Copy link
Collaborator

Zhirnoff commented Jan 28, 2025

Description
When inserting a molecule using setMolecule and "Paste from Clipboard,"/"Open from File" the zoom behavior differs. Specifically, after the first paste via "Paste from Clipboard,"/"Open from File" the zoom level changes, causing the molecule to be placed outside the visible canvas when using setMolecule.

Steps to Reproduce

  1. Open Ketcher -> Macro mode -> Flex
  2. Insert the attached molecule via "Paste from Clipboard." or "Open from File" macromol (1).zip

Generated by WebMolKit

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 3 2 0 0 1
M  V30 BEGIN ATOM
M  V30 1 C 1.2500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(2 2 Br)
M  V30 2 D 2.7500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(4 1 Al 3 Br)
M  V30 3 E 4.2500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(2 2 Al)
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 END BOND
M  V30 END CTAB
M  V30 BEGIN TEMPLATE
M  V30 TEMPLATE 1 AA/C/C/ NATREPLACE=AA/C
M  V30 BEGIN CTAB
M  V30 COUNTS 9 8 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 2.1685 -1.6999 0.0000 0
M  V30 2 C 0.2180 -0.5760 0.0000 0
M  V30 3 C 0.2145 1.6752 0.0000 0
M  V30 4 S -1.7359 2.7992 0.0000 0
M  V30 5 N -1.7327 -1.6999 0.0000 0
M  V30 6 O 2.1713 -3.5000 0.0000 0
M  V30 7 O 3.7263 -0.7980 0.0000 0
M  V30 8 H -3.2913 -0.7996 0.0000 0
M  V30 9 H -1.7387 4.5991 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 2 6 1
M  V30 2 1 1 2
M  V30 3 1 1 7
M  V30 4 1 2 5
M  V30 5 1 2 3 CFG=1
M  V30 6 1 3 4
M  V30 7 1 5 8
M  V30 8 1 4 9
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 8) XBONDS=(1 7) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 7) XBONDS=(1 3) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 9) XBONDS=(1 8) CLASS=LGRP
M  V30 4 SUP 0 LABEL=C ATOMS=(6 1 2 3 4 5 6) XBONDS=(3 3 7 8) CLASS=AA NATREPLACE=AA/C SAP=(3 5 8 Al) SAP=(3 1 7 Br) SAP=(3 4 9 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 TEMPLATE 2 AA/D/D/ NATREPLACE=AA/D
M  V30 BEGIN CTAB
M  V30 COUNTS 11 10 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 2.4465 -2.3367 0.0000 0
M  V30 2 O 2.4491 -4.1088 0.0000 0
M  V30 3 C 0.5261 -1.2302 0.0000 0
M  V30 4 N -1.3942 -2.3367 0.0000 0
M  V30 5 H -2.9287 -1.4504 0.0000 0
M  V30 6 C 0.5227 0.9862 0.0000 0
M  V30 7 C -1.3975 2.0928 0.0000 0
M  V30 8 O -2.9313 1.2048 0.0000 0
M  V30 9 O -1.4002 3.8649 0.0000 0
M  V30 10 O 3.9801 -1.4487 0.0000 0
M  V30 11 H 0.1276 4.7626 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 2 2 1
M  V30 2 1 1 3
M  V30 3 1 3 4
M  V30 4 1 4 5
M  V30 5 1 3 6 CFG=1
M  V30 6 1 6 7
M  V30 7 2 7 8
M  V30 8 1 7 9
M  V30 9 1 1 10
M  V30 10 1 9 11
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 5) XBONDS=(1 4) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 10) XBONDS=(1 9) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 11) XBONDS=(1 10) CLASS=LGRP
M  V30 4 SUP 0 LABEL=D ATOMS=(8 1 2 3 4 6 7 8 9) XBONDS=(3 4 9 10) CLASS=AA NATREPLACE=AA/D SAP=(3 4 5 Al) SAP=(3 1 10 Br) SAP=(3 9 11 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 TEMPLATE 3 AA/E/E/ NATREPLACE=AA/E
M  V30 BEGIN CTAB
M  V30 COUNTS 12 11 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 0.5163 -2.2165 0.0000 0
M  V30 2 C 2.4366 -3.3231 0.0000 0
M  V30 3 O 2.4392 -5.0952 0.0000 0
M  V30 4 O 3.9703 -2.4351 0.0000 0
M  V30 5 N -1.4042 -3.3231 0.0000 0
M  V30 6 H -2.9386 -2.4367 0.0000 0
M  V30 7 C 0.5129 -0.0002 0.0000 0
M  V30 8 C -1.4075 1.1063 0.0000 0
M  V30 9 C -1.4109 3.3227 0.0000 0
M  V30 10 O -2.9463 4.2073 0.0000 0
M  V30 11 O 0.1229 4.2107 0.0000 0
M  V30 12 H 0.1094 5.9828 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 2 1
M  V30 2 2 2 3
M  V30 3 1 2 4
M  V30 4 1 1 5
M  V30 5 1 5 6
M  V30 6 1 1 7 CFG=1
M  V30 7 1 7 8
M  V30 8 1 8 9
M  V30 9 2 9 10
M  V30 10 1 9 11
M  V30 11 1 11 12
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 6) XBONDS=(1 5) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 4) XBONDS=(1 3) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 12) XBONDS=(1 11) CLASS=LGRP
M  V30 4 SUP 0 LABEL=E ATOMS=(9 1 2 3 5 7 8 9 10 11) XBONDS=(3 3 5 11) CLASS=AA NATREPLACE=AA/E SAP=(3 5 6 Al) SAP=(3 2 4 Br) SAP=(3 11 12 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 END TEMPLATE
M  END

  1. Observe that the zoom level changes.
  2. Now, insert the same molecule via setMolecule in DevTool Console
ketcher.setMolecule(`
Generated by WebMolKit

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 3 2 0 0 1
M  V30 BEGIN ATOM
M  V30 1 C 1.2500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(2 2 Br)
M  V30 2 D 2.7500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(4 1 Al 3 Br)
M  V30 3 E 4.2500 -1.2500 0.0000 0 CLASS=AA ATTCHORD=(2 2 Al)
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 END BOND
M  V30 END CTAB
M  V30 BEGIN TEMPLATE
M  V30 TEMPLATE 1 AA/C/C/ NATREPLACE=AA/C
M  V30 BEGIN CTAB
M  V30 COUNTS 9 8 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 2.1685 -1.6999 0.0000 0
M  V30 2 C 0.2180 -0.5760 0.0000 0
M  V30 3 C 0.2145 1.6752 0.0000 0
M  V30 4 S -1.7359 2.7992 0.0000 0
M  V30 5 N -1.7327 -1.6999 0.0000 0
M  V30 6 O 2.1713 -3.5000 0.0000 0
M  V30 7 O 3.7263 -0.7980 0.0000 0
M  V30 8 H -3.2913 -0.7996 0.0000 0
M  V30 9 H -1.7387 4.5991 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 2 6 1
M  V30 2 1 1 2
M  V30 3 1 1 7
M  V30 4 1 2 5
M  V30 5 1 2 3 CFG=1
M  V30 6 1 3 4
M  V30 7 1 5 8
M  V30 8 1 4 9
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 8) XBONDS=(1 7) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 7) XBONDS=(1 3) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 9) XBONDS=(1 8) CLASS=LGRP
M  V30 4 SUP 0 LABEL=C ATOMS=(6 1 2 3 4 5 6) XBONDS=(3 3 7 8) CLASS=AA NATREPLACE=AA/C SAP=(3 5 8 Al) SAP=(3 1 7 Br) SAP=(3 4 9 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 TEMPLATE 2 AA/D/D/ NATREPLACE=AA/D
M  V30 BEGIN CTAB
M  V30 COUNTS 11 10 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 2.4465 -2.3367 0.0000 0
M  V30 2 O 2.4491 -4.1088 0.0000 0
M  V30 3 C 0.5261 -1.2302 0.0000 0
M  V30 4 N -1.3942 -2.3367 0.0000 0
M  V30 5 H -2.9287 -1.4504 0.0000 0
M  V30 6 C 0.5227 0.9862 0.0000 0
M  V30 7 C -1.3975 2.0928 0.0000 0
M  V30 8 O -2.9313 1.2048 0.0000 0
M  V30 9 O -1.4002 3.8649 0.0000 0
M  V30 10 O 3.9801 -1.4487 0.0000 0
M  V30 11 H 0.1276 4.7626 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 2 2 1
M  V30 2 1 1 3
M  V30 3 1 3 4
M  V30 4 1 4 5
M  V30 5 1 3 6 CFG=1
M  V30 6 1 6 7
M  V30 7 2 7 8
M  V30 8 1 7 9
M  V30 9 1 1 10
M  V30 10 1 9 11
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 5) XBONDS=(1 4) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 10) XBONDS=(1 9) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 11) XBONDS=(1 10) CLASS=LGRP
M  V30 4 SUP 0 LABEL=D ATOMS=(8 1 2 3 4 6 7 8 9) XBONDS=(3 4 9 10) CLASS=AA NATREPLACE=AA/D SAP=(3 4 5 Al) SAP=(3 1 10 Br) SAP=(3 9 11 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 TEMPLATE 3 AA/E/E/ NATREPLACE=AA/E
M  V30 BEGIN CTAB
M  V30 COUNTS 12 11 4 0 1
M  V30 BEGIN ATOM
M  V30 1 C 0.5163 -2.2165 0.0000 0
M  V30 2 C 2.4366 -3.3231 0.0000 0
M  V30 3 O 2.4392 -5.0952 0.0000 0
M  V30 4 O 3.9703 -2.4351 0.0000 0
M  V30 5 N -1.4042 -3.3231 0.0000 0
M  V30 6 H -2.9386 -2.4367 0.0000 0
M  V30 7 C 0.5129 -0.0002 0.0000 0
M  V30 8 C -1.4075 1.1063 0.0000 0
M  V30 9 C -1.4109 3.3227 0.0000 0
M  V30 10 O -2.9463 4.2073 0.0000 0
M  V30 11 O 0.1229 4.2107 0.0000 0
M  V30 12 H 0.1094 5.9828 0.0000 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 2 1
M  V30 2 2 2 3
M  V30 3 1 2 4
M  V30 4 1 1 5
M  V30 5 1 5 6
M  V30 6 1 1 7 CFG=1
M  V30 7 1 7 8
M  V30 8 1 8 9
M  V30 9 2 9 10
M  V30 10 1 9 11
M  V30 11 1 11 12
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 LABEL=H ATOMS=(1 6) XBONDS=(1 5) CLASS=LGRP
M  V30 2 SUP 0 LABEL=OH ATOMS=(1 4) XBONDS=(1 3) CLASS=LGRP
M  V30 3 SUP 0 LABEL=H ATOMS=(1 12) XBONDS=(1 11) CLASS=LGRP
M  V30 4 SUP 0 LABEL=E ATOMS=(9 1 2 3 5 7 8 9 10 11) XBONDS=(3 3 5 11) CLASS=AA NATREPLACE=AA/E SAP=(3 5 6 Al) SAP=(3 2 4 Br) SAP=(3 11 12 Cx)
M  V30 END SGROUP
M  V30 END CTAB
M  V30 END TEMPLATE
M  END`)
  1. Notice that the molecule is placed outside the visible canvas.

Actual behavior
After pasting a molecule via "Paste from Clipboard," the zoom level changes.
When inserting via setMolecule, the molecule is placed outside the visible canvas.

Expected behavior
The behavior of inserting molecules should be consistent across setMolecule and "Paste from Clipboard." and "Open from File"
The molecule should remain visible on the canvas in both cases.

Screenshots

2025-01-28_11h43_02.mp4

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 131.0.6778.205 (Official Build) (64-bit)

Ketcher version
[Version 3.0.0-rc.4]
Indigo version
[Version 1.28.0-rc.3]

@Zhirnoff Zhirnoff added API Common UI problems Bucket: Common UI problems Priority: High Severity: Low Low level visibility to the user User`s Feedback labels Jan 28, 2025
@Zhirnoff Zhirnoff added this to the Ketcher 3.0.0-rc.5 milestone Jan 28, 2025
@Zhirnoff Zhirnoff changed the title Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File Jan 28, 2025
@rrodionov91 rrodionov91 self-assigned this Jan 28, 2025
rrodionov91 added a commit that referenced this issue Jan 28, 2025
…olecule and Paste from Clipboard/Open from File

- added autozoom for setMolecule and addFragment in macro mode
rrodionov91 added a commit that referenced this issue Jan 28, 2025
…olecule and Paste from Clipboard/Open from File (#6373)

* #6370 - Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File
- added autozoom for setMolecule and addFragment in macro mode

#6375 - Ketcher renders editor twice in dev mode
- removed react strict mode from editor

- updated ketcher to 3.0.0-rc.5
@Zhirnoff
Copy link
Collaborator Author

Tested. Bug fixed.

2025-01-28_18h35_15.mp4

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 131.0.6778.205 (Official Build) (64-bit)

Ketcher version
[Version 3.0.0-rc.5]
Indigo version
[Version 1.28.0-rc.3]

rrodionov91 added a commit that referenced this issue Jan 28, 2025
…olecule and Paste from Clipboard/Open from File (#6373)

* #6370 - Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File
- added autozoom for setMolecule and addFragment in macro mode

#6375 - Ketcher renders editor twice in dev mode
- removed react strict mode from editor
rrodionov91 added a commit that referenced this issue Jan 28, 2025
…olecule and Paste from Clipboard/Open from File (#6373) (#6376)

* #6370 - Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File
- added autozoom for setMolecule and addFragment in macro mode

#6375 - Ketcher renders editor twice in dev mode
- removed react strict mode from editor
AlexeyGirin pushed a commit that referenced this issue Jan 28, 2025
…olecule and Paste from Clipboard/Open from File (#6373) (#6376)

* #6370 - Inconsistent zoom behavior when inserting a molecule via setMolecule and Paste from Clipboard/Open from File
- added autozoom for setMolecule and addFragment in macro mode

#6375 - Ketcher renders editor twice in dev mode
- removed react strict mode from editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment