OCL editor does not catch key events
When pressing 'c' in the prediction tool the atom is converted to 'C' but the event bubbles and the spectrum is centered as well
@targos Not sure where it should be fixed.
We could add a "stopPropagation" to the OCL editor but it's not even sure we listen to the same events. Normally it's up to the event listener to only handle the event it cares about. I'd say NMRium should filter the events that are not on expected targets (this is a general issue that can happen with any component used inside NMRium).
So the one letter shortcuts + the numbers to store the view state should only be active if the mouse if over the spectrum of left toolbar
Do we agree on this ? @hamed-musallam ?
It should not be based on where the mouse is located, but on the value of event.target
For KeyListener, we used a global listener. I remember we did it that way, in case we had multiple viewers.
@hamed-musallam Could you add a condition in the global listener to ignore the event if the event if over the ocl-editor ? Something like:
const specificDiv = document.getElementById('your-div-id');
if (specificDiv && specificDiv.contains(event.target)) {
event.stopPropagation();
}
In fact because ocl-editor is in a shadow dom the event target will always be the element on which the shadow dom element is attached. Michael will add an identifier on the element.
[email protected] sets a custom attribute on the root editor element: https://github.com/cheminfo/openchemlib-js/pull/305