Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left key handler is not triggered in an empty editor #2005

Closed
christianhg opened this issue Mar 7, 2018 · 6 comments
Closed

Left key handler is not triggered in an empty editor #2005

christianhg opened this issue Mar 7, 2018 · 6 comments

Comments

@christianhg
Copy link

Steps for Reproduction

  1. Visit https://codepen.io/christianhg/pen/bLXOwL
  2. Place cursor in the editor
  3. Press the right key
  4. Notice that "right" is printed in the console
  5. Press the left key

Expected behavior: "left" is printed in the console

Actual behavior: the left key handler isn't called

Platforms:

MacOS 10.13.3
Chrome 64

Version: 1.3.5

@christianhg
Copy link
Author

@jhchen Would this be a good first bug? If so, I could give it a shot.

@atifsyedali
Copy link

I came across this too. I worked around it temporarily by binding onKeyDown in addition to the binding in the keyboard module.

@tsupei
Copy link

tsupei commented Oct 11, 2021

Is there any good solution for this issue? I found that this issue also occurs for the backspace key

@tomwalters
Copy link

I came across this issue and dug into the existing default bindings for the arrow keys, eventually landing on "embed left" - https://github.com/quilljs/quill/blob/0f20a58acece17853cfec8c177543108733e722c/modules/keyboard.js#L538

This default handler returns false which prevents additional handlers from firing as per the docs. I'm not sure why this is in core, but this is what's causing the issue.

Grabbing the name of this binding and overwriting it in my own configuration enables me to fire the event handler:

keyBindings: {
  'embed left': {
    key: 37, /* Left arrow */
    collapsed: true,
    offset: 0,
    handler: (range, ctx) => {}
  }
}

It's not a great solution as it overwrites this handler, but it works™.

@tommyc38
Copy link

This relates to #2423. Rather than overwriting Quill's keyboard binding, you can give the keybinding a numerical name (e.g. 1) vs embed left. This will make your keybinding have higher priority than Quill's (e.g. their documentation is wrong with regard to how quill gives priority over default keybindings which is stated in #2423). It's a hack but hopefully some keyboard api updates will be coming to address these issues. Hopefully this helps someone.

@quill-bot
Copy link

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants