-
-
Notifications
You must be signed in to change notification settings - Fork 143
Description
Problem
@krassowski (jupyterlab/jupyterlab#15897 (comment)):
As summarised in jupyterlab/jupyterlab#14115 (comment), with changes from listening to keydown events in capture phase to listening to them in bubbling phase (JupyterLab 4.1) we lost ability to preventDefault() the default CodeMirror shortcuts behaviour. The current solution is to override respective CM commands manually (as in jupyterlab/jupyterlab#15898) and check if it should possibly be prevented (e.g. based on the class of a closest DOM node), but it does not work if user disables such a command or changes the shortcut.
Proposed Solution
@krassowski (jupyterlab/jupyterlab#15897 (comment)):
- Make it a property of lumino's IKeybinding so some shortcuts can be invoked already in capture phase and others only in bubbling phase
Based on initial review, in order to implement option 2, it seems like another addEventListener() needs to be added around
lumino/packages/application/src/index.ts
Line 359 in 20cf366
| document.addEventListener('keydown', this, !this._bubblingKeydown); |
so that one event listener has
useCapture (the last argument) as true and the other has false, so that both capture and bubbling phases trigger the callback.
And then something like #689 needs to be added so that key bindings are processed based on whether a new IKeyBinding capture phase flag is true for a particular key binding.
Help with implementing this or suggestions for how to implement this are welcome.
Additional context
jupyterlab/jupyterlab#15897
jupyterlab-contrib/jupyterlab-vim#138