cheminfo / cheminfo/openchemlib-js
Inconsistent Behavior in Bond Highlighting and Atom Coloring Between MOLECULE and REACTION Modes
- Dominant language
- Java
- Stars
- 89
- Forks
- 25
- Avg merge
- 51m
- Merged PRs (30d)
- 1
Description
**Issue Description:**
I'm encountering an issue when using programmatic bond highlighting and atom coloring with the `CanvasEditorElement` in the [openchemlib-vaadin](https://github.com/artaius/openchemlib-vaadin) component of openchemlib-js. The behavior differs between `MOLECULE` and `REACTION` modes.
**Expected Behavior:**
In `MOLECULE` mode, applying bond highlighting and atom coloring works as expected. For example:
```javascript
import OCL from 'openchemlib/full.pretty.js';
const CanvasEditorElement = OCL.registerCustomElement();
CanvasEditorElement.prototype.init = function() {
const molecule = this.getMolecule();
molecule.setBondBackgroundHiliting(0, true);
molecule.setAtomColor(0, 0x000080);
this.moleculeChanged();
}
```
**Observed Behavior in REACTION Mode:**
When I use a similar approach in `REACTION` mode, the changes are not reflected in the editor. It seems that the arrays on the underlying `StereoMolecule` (namely `mBondFlags` and `mAtomFlags`) might be getting cleared before rendering. Here's the snippet used:
```javascript
import OCL from 'openchemlib/full.pretty.js';
const CanvasEditorElement = OCL.registerCustomElement();
CanvasEditorElement.prototype.init = function() {
const molecule = this.getReaction().getProduct(0);
molecule.setBondBackgroundHiliting(0, true);
molecule.setAtomColor(0, 0x000080);
this.moleculeChanged();
}
```
**Request for Clarification:**
Could you please advise if this behavior in `REACTION` mode is known or intended? If not, it might indicate a bug. Any guidance or suggestions for a workaround would be greatly appreciated.
Thank you for your time and assistance!
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with CanvasEditorElement in MOLECULE and REACTION modes using the examples in the report. Compare getMolecule() with getReaction().getProduct(0) around moleculeChanged(), and verify that bond highlighting and atom coloring remain visible in both modes; document the intended behavior if the difference is deliberate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100