FIX: Hide popup-menu options when typing.

This commit is contained in:
Guo Xiang Tan 2016-06-20 10:12:01 +08:00
parent a053caeda4
commit fd800b544f
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72

View File

@ -7,6 +7,10 @@ export default Ember.Component.extend({
_setup() {
this.appEvents.on("popup-menu:open", this, "_changeLocation");
$('html').on(`keydown.popup-menu-${this.get('elementId')}`, () => {
this.sendAction('hide');
});
$('html').on(`mouseup.popup-menu-${this.get('elementId')}`, (e) => {
const $target = $(e.target);
if ($target.is("button") || this.$().has($target).length === 0) {
@ -18,6 +22,7 @@ export default Ember.Component.extend({
@on('willDestroyElement')
_cleanup() {
$('html').off(`mouseup.popup-menu-${this.get('elementId')}`);
$('html').off(`keydown.popup-menu-${this.get('elementId')}`);
this.appEvents.off("popup-menu:open", this, "_changeLocation");
},