1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

🐛 Koenig - Fix Firefox adding "ArrowUp" or similar to caption fields

refs https://github.com/TryGhost/Ghost/issues/9623
- Firefox unlike other browsers triggers `keypress` events for non-printable characters
- use mobiledoc-kit's `Key` class to guard against adding non-printable key values to captions
This commit is contained in:
Kevin Ansfield 2018-06-21 17:57:45 +01:00
parent fe840a2f93
commit 620c8fcd04

View file

@ -1,4 +1,5 @@
import Component from '@ember/component';
import Key from 'mobiledoc-kit/utils/key';
import layout from '../templates/components/koenig-caption-input';
import {computed} from '@ember/object';
import {kgStyle} from 'ember-cli-ghost-spirit/helpers/kg-style';
@ -64,8 +65,9 @@ export default Component.extend({
// that it's possible to start typing without explicitly focusing the input
_handleKeypress(event) {
let captionInput = this.element.querySelector('[name="caption"]');
let key = new Key(event);
if (captionInput && captionInput !== document.activeElement) {
if (captionInput && captionInput !== document.activeElement && key.isPrintableKey()) {
captionInput.value = `${captionInput.value}${event.key}`;
captionInput.focus();
event.preventDefault();