Fixed preview shortcut not working when billing app is enabled

no issue

- the billing modal is always rendered, it's contents being shown/hidden via CSS
- when the billing modal was rendered it was changing the `key` scope and binding the enter key, however because it's always rendered this was messing with the default key scope for all other areas of the app
- removed all keyboard handling from the billing modal because it wasn't actually doing anything (there is nothing to handle the "confirm" action when Enter is pressed) which fixes the unexpected key scope change
This commit is contained in:
Kevin Ansfield 2021-03-10 16:15:19 +00:00
parent d3b3a0117d
commit cce71e5517
3 changed files with 5 additions and 35 deletions

View File

@ -1,42 +1,11 @@
/* global key */
import Component from '@ember/component';
import {computed} from '@ember/object';
import {run} from '@ember/runloop';
import {inject as service} from '@ember/service';
export default Component.extend({
billing: service(),
visibilityClass: computed('billing.billingWindowOpen', function () {
return this.billing.get('billingWindowOpen') ? 'gh-billing' : 'gh-billing closed';
}),
didInsertElement() {
this._super(...arguments);
this._setupShortcuts();
},
willDestroyElement() {
this._super(...arguments);
this._removeShortcuts();
},
_setupShortcuts() {
run(function () {
document.activeElement.blur();
});
this._previousKeymasterScope = key.getScope();
key('enter', 'modal', () => {
this.send('confirm');
});
key.setScope('modal');
},
_removeShortcuts() {
key.unbind('enter', 'modal');
key.setScope(this._previousKeymasterScope);
}
visibilityClass: computed('billingWindowOpen', function () {
return this.billingWindowOpen ? 'gh-billing' : 'gh-billing closed';
})
});

View File

@ -4,6 +4,7 @@ import {computed} from '@ember/object';
import {inject as service} from '@ember/service';
export default Controller.extend({
billing: service(),
customViews: service(),
config: service(),
dropdown: service(),

View File

@ -12,7 +12,7 @@
{{outlet}}
{{#if this.showBilling}}
<GhBillingModal />
<GhBillingModal @billingWindowOpen={{this.billing.billingWindowOpen}} />
{{/if}}
</main>