mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05: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:
parent
06e6f42224
commit
821696a7d7
1 changed files with 3 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue