mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fix cmd-s shortcut not saving changes in text fields with focusout
closes #4556 - when <kbd>CMD-S</kbd> is used, if the focused element is an input, trigger it's `focusout` handler then schedule the save action to happen after any actions resulting from the trigger
This commit is contained in:
parent
c8d0e25923
commit
5b1178c7c5
1 changed files with 10 additions and 2 deletions
|
@ -3,7 +3,7 @@ import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
|
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
|
||||||
|
|
||||||
const {Mixin, RSVP, run} = Ember;
|
const {$, Mixin, RSVP, run} = Ember;
|
||||||
|
|
||||||
let generalShortcuts = {};
|
let generalShortcuts = {};
|
||||||
generalShortcuts[`${ctrlOrCmd}+alt+p`] = 'publish';
|
generalShortcuts[`${ctrlOrCmd}+alt+p`] = 'publish';
|
||||||
|
@ -16,7 +16,15 @@ export default Mixin.create(styleBody, ShortcutsRoute, {
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
|
let selectedElement = $(document.activeElement);
|
||||||
|
|
||||||
|
if (selectedElement.is('input[type="text"]')) {
|
||||||
|
selectedElement.trigger('focusout');
|
||||||
|
}
|
||||||
|
|
||||||
|
run.scheduleOnce('actions', this, function () {
|
||||||
this.get('controller').send('save');
|
this.get('controller').send('save');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
publish() {
|
publish() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue