There is a spot where we monkey-patch the Lumino CommandRegistry's processKeydownEvent method and it is occasionally brittle, causing command invocations to fail. This seems like an anti-pattern for two reasons:
- We are overriding the entire application's command registry and can cause other extensions to fail.
- We are relying on an object we've attached to the
window object instead of a local variable.
app.commands.processKeydownEvent = (event) => {
if (window.beakerx.tableFocused) {
return false;
}
return originalProcessFn.call(app.commands, event);
};
https://github.com/twosigma/beakerx_widgets/blob/master/beakerx_widgets/js/src/lab/BeakerxWidgetExtension.ts#L67-L69
This problem is sometimes triggered when a user changes the kernel on an active notebook multiple times. One user reported that after switching the kernel a second or third time, the window.beakerx object is undefined so the handler fails while trying to access the tableFocused attribute.