Skip to content

Commit 6b49072

Browse files
committed
fix: only emit OCL editor changes when event is from user and updates the molecule/reaction
1 parent 778f704 commit 6b49072

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/modules/types/science/chemistry/ocl_editor/controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ define([
160160
};
161161

162162
Controller.prototype.onChange = function (event, molecule) {
163+
if (!event.isUserEvent) return;
163164
const inPlace = this.module.getConfigurationCheckbox('prefs', 'inPlace');
164165

165166
// In modify variable in mode

src/modules/types/science/chemistry/ocl_editor/view.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ define(['modules/default/defaultview', 'src/util/ui', 'openchemlib'], function (
130130
initEditor() {
131131
const controller = this.module.controller;
132132
this.editor = new OCL.CanvasEditor(this.dom.get(0));
133-
this.editor.setOnChangeListener((event) =>
134-
controller.onChange(event, this.editor.getMolecule()),
135-
);
133+
this.editor.setOnChangeListener((event) => {
134+
if (event.type !== 'molecule') return;
135+
controller.onChange(event, this.editor.getMolecule());
136+
});
136137
this.editor.setMolecule(
137138
OCL.Molecule.fromIDCode(
138139
controller.currentMol.idCode,

src/modules/types/science/chemistry/ocl_reaction_editor/controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ define([
135135
};
136136

137137
Controller.prototype.onChange = function (event, reaction) {
138+
if (!event.isUserEvent) return;
138139
const inPlace = this.module.getConfigurationCheckbox('prefs', 'inPlace');
139140
const idCode = OCL.ReactionEncoder.encode(reaction) || '';
140141
const rxn = reaction.toRxn();

src/modules/types/science/chemistry/ocl_reaction_editor/view.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ define(['modules/default/defaultview', 'src/util/ui', 'openchemlib'], function (
9898
initialMode: 'reaction',
9999
});
100100
this.editor.setOnChangeListener((event) => {
101+
if (event.type !== 'molecule') return;
101102
const reaction = this.editor.getReaction();
102103
this._currentReaction = reaction;
103104
this.module.controller.onChange(event, reaction);

0 commit comments

Comments
 (0)