From 5eb936d8c2ddb3dfd9bb2e73b876003875c9afbe Mon Sep 17 00:00:00 2001 From: Guillaume Martigny Date: Wed, 3 Feb 2016 09:19:21 +0100 Subject: [PATCH] fix #392 Signed-off-by:Guillaume Martigny --- src/js/controller/settings/SettingsController.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/js/controller/settings/SettingsController.js b/src/js/controller/settings/SettingsController.js index 0988011f..e8a1e935 100644 --- a/src/js/controller/settings/SettingsController.js +++ b/src/js/controller/settings/SettingsController.js @@ -33,6 +33,7 @@ ns.SettingsController = function (piskelController) { this.piskelController = piskelController; + this.closeDrawerShortcut = pskl.service.keyboard.Shortcuts.MISC.CLOSE_POPUP; this.settingsContainer = document.querySelector('[data-pskl-controller=settings]'); this.drawerContainer = document.getElementById('drawer-container'); this.isExpanded = false; @@ -87,6 +88,8 @@ this.currentController = new settings[setting].controller(this.piskelController); this.currentController.init(); + pskl.app.shortcutService.registerShortcut(this.closeDrawerShortcut, this.closeDrawer_.bind(this)); + pskl.utils.Dom.removeClass(SEL_SETTING_CLS); var selectedSettingButton = document.querySelector('[data-setting=' + setting + ']'); if (selectedSettingButton) { @@ -109,9 +112,12 @@ }; ns.SettingsController.prototype.destroyCurrentController_ = function () { - if (this.currentController && this.currentController.destroy) { - this.currentController.destroy(); - this.currentController = null; + if (this.currentController) { + pskl.app.shortcutService.unregisterShortcut(this.closeDrawerShortcut); + if (this.currentController.destroy) { + this.currentController.destroy(); + this.currentController = null; + } } }; })();