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

Switching tabs by pressing the ctrl or metakey, then clicking back to sir trevor tab causes pressing 'b' key to turn on bold #516

Closed
tiffanywei opened this issue Oct 1, 2016 · 0 comments

Comments

@tiffanywei
Copy link
Contributor

This happened in my project where if someone has the text block focused and then switches tabs by using a shortcut with the ctrl or metakey (eg ctrl + tab in chrome) and switches back to the Sir Trevor tab by clicking on the tab, Sir Trevor will register the keydown event, but not the keyup event, thus the ctrlDown state in src/block.js stays true and if the next keydown is a command keycode, it will execute that command.

This can be reproduced in the Sir Trevor docs example.
http://madebymany.github.io/sir-trevor-js/example.html

  1. Focus on a text block.
  2. ctrl + tab to switch tabs
  3. click back on the original tab
  4. press the 'b' key
  5. typing more keys will be in bold

I fixed this in my project by replacing lines src/block.js:367-383 with

Events.delegate(block.el, '.st-text-block', 'keydown', function (ev) {
  if ((ev.metaKey || ev.ctrlKey) && ev.keyCode === cmd.keyCode) {
    ev.preventDefault();
    block.execTextBlockCommand(cmd.cmd);
  }
});

Should I open a PR for this?

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

2 participants