Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🐛 Fixed 'c' and 'k' chars not working in Unsplash search when adding …
Browse files Browse the repository at this point in the history
…tag cover

closes TryGhost/Ghost#9147
- change the keymaster scope when the unsplash search input has focus so the route's registered shortcuts aren't accidentally triggered
  • Loading branch information
kevinansfield committed Jan 12, 2018
1 parent d33df82 commit 8b3c92e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/components/gh-unsplash.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global key */
import Component from '@ember/component';
import ShortcutsMixin from 'ghost-admin/mixins/shortcuts';
import {bind} from '@ember/runloop';
Expand Down Expand Up @@ -26,7 +27,7 @@ export default Component.extend(ShortcutsMixin, {
this._super(...arguments);

this.shortcuts = {
escape: 'handleEscape'
escape: {action: 'handleEscape', scope: 'all'}
};
},

Expand All @@ -38,9 +39,10 @@ export default Component.extend(ShortcutsMixin, {
},

willDestroyElement() {
this._super(...arguments);
this.get('resizeDetector').teardown('.gh-unsplash', this._resizeCallback);
this.removeShortcuts();
this.send('resetKeyScope');
this._super(...arguments);
},

actions: {
Expand Down Expand Up @@ -70,6 +72,14 @@ export default Component.extend(ShortcutsMixin, {
this.get('unsplash').retryLastRequest();
},

setKeyScope() {
key.setScope('unsplash');
},

resetKeyScope() {
key.setScope('default');
},

handleEscape() {
if (!this.get('zoomedPhoto')) {
this.close();
Expand Down
2 changes: 2 additions & 0 deletions app/templates/components/gh-unsplash.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
placeholder="Search free high-resolution photos"
tabindex="1"
autocorrect="off"
focusIn=(action "setKeyScope")
focusOut=(action "resetKeyScope")
update=(action "updateSearch" target=unsplash)
}}
</span>
Expand Down

0 comments on commit 8b3c92e

Please sign in to comment.