EventHelper
has globally visible breaking side effects
#5480
Labels
Milestone
EventHelper
has globally visible breaking side effects
#5480
The
EventHelper
callsfixEvent
on any event for which a handler has been added. This applies a good number of "fixes" on that event object, which can cause unexpected side effects in other parts of the application.In our particular case this is the breaking part (
Core/helper/EventHelper.js
line 397-401 for@bryntum/schedulerpro@5.1.5
):Which makes all key events that have the
meta
key pressed look as if the user also pressed thectrl
key, for any parts of the application. In a different library for keyboard handling, where we have ameta+k
keyboard shortcut defined, this causes the event matching to fail, as the library would (correctly IMO!) do a complete check on all modifier keys. So (assuming a Mac here) when a user presses ⌘K it would only match themeta+k
shortcut, if thectrl
modifier key is not pressed. But those "fixes" make it look as if both ⌘ and ctrl have been pressed.I don't know if any of the other "fixes" have the potential to break application code, but frankly I believe that the approach of mutating the native browser event, including properties that are (for a reason!?) read-only, is a quite bad idea! If bryntum needs that kind of event fixes or normalization, it could totally handle that internally (e.g. by passing an internal custom event representation around), without global side effects.
Also these event "fixes" live for the whole lifespan of the app (assuming a SPA here), even when the scheduler widget has been torn down, as the
EventHelper
callsEH.on()
(Line 948) in module space, and that listener never gets removed. Having the weird but not breaking side effect of adding the.b-using-keyboard
class to<body>
, even when not a single bryntum widget is active anymore...The text was updated successfully, but these errors were encountered: