Closed krassowski closed 8 months ago
Here are some more thoughts:
willPreventDefault
is a bit single-use case method which needs to be called in a very specific way (after previous processKeydownEvent
but before next processKeydownEvent
). I don't like it from the API design perspective.processKeydownEvent
if it find that user input arises from a new key event; this can still result in a command being dispatched if it was a partial match; we need a better solution on lumino levelCurrently thinking about adding some kind of a hook in _executeKeyBinding
but don't see a clean API for it yet.
Problem
preventDefault()
andstopPropagation()
on matched keyboard events)Proposed Solution
preventDefault: bool = true
toIKeyBindingOptions
Add new public method on commands to check if the default action on the event should be prevented, say:
Change
processKeydownEvent
to onlypreventDefault
when needed, this is change: https://github.com/jupyterlab/lumino/blob/f1014291ac83e4524bbf57afb2cbdd55ea4ee546/packages/commands/src/index.ts#L553-L557to:
evtKeydown
handler to callwillPreventDefault(event)
and depending on the result decide whether to process the event immediately or notpreventDefault
default tofalse
, and adopting the refinedevtKeydown
implementation from JupyterLabAdditional context