samuelbetio / storyofmylife

Samuel Betio's clean lines and stylish design will give your site the perfect platform to stand out from the crowd. In modern web design content is everything and our Samuel Betio template puts its focus on just that.
https://goo.gl/8KacYq
MIT License
17 stars 22 forks source link

Rich content editing entirely re-imagined for the web #42

Closed lmas2969 closed 6 years ago

lmas2969 commented 6 years ago

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

  if ((ev.metaKey || ev.ctrlKey) && ev.keyCode === cmd.keyCode) {
    ev.preventDefault();
    block.execTextBlockCommand(cmd.cmd);
  }
});

Should I open a PR for this?