From e5911e7fc4f4418055facd1aca3451a974d684a3 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 31 Aug 2015 14:51:38 -0400 Subject: [PATCH] FIX: Opening panels by keyboard should respect closing --- app/assets/javascripts/discourse/controllers/header.js.es6 | 5 +++++ .../javascripts/discourse/lib/keyboard-shortcuts.js.es6 | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/header.js.es6 b/app/assets/javascripts/discourse/controllers/header.js.es6 index f81ec83cdd2..813e9e717ec 100644 --- a/app/assets/javascripts/discourse/controllers/header.js.es6 +++ b/app/assets/javascripts/discourse/controllers/header.js.es6 @@ -18,6 +18,11 @@ const HeaderController = Ember.Controller.extend({ actions: { + toggleMenuPanel(visibleProp) { + this.toggleProperty(visibleProp); + this.appEvents.trigger('dropdowns:closeAll'); + }, + toggleStar() { const topic = this.get('topic'); if (topic) topic.toggleStar(); diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 221fac0ff5d..26f716c1f30 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -65,6 +65,7 @@ export default { this.searchService = this.container.lookup('search-service:main'); + this.appEvents = this.container.lookup('app-events:main'); _.each(PATH_BINDINGS, this._bindToPath, this); _.each(CLICK_BINDINGS, this._bindToClick, this); @@ -169,15 +170,15 @@ export default { }, showSearch() { - this.container.lookup('controller:header').toggleProperty('searchVisible'); + this.container.lookup('controller:header').send('toggleMenuPanel', 'searchVisible'); }, toggleHamburgerMenu() { - this.container.lookup('controller:header').toggleProperty('hamburgerVisible'); + this.container.lookup('controller:header').send('toggleMenuPanel', 'hamburgerVisible'); }, showCurrentUser() { - this.container.lookup('controller:header').toggleProperty('userMenuVisible'); + this.container.lookup('controller:header').send('toggleMenuPanel', 'userMenuVisible'); }, showHelpModal() {