Skip to content

Overriding the command registry keydown handler causes shortcut execution errors. #55

@afshin

Description

@afshin

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:

  1. We are overriding the entire application's command registry and can cause other extensions to fail.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions