FIX: Close menus when clicking on notifications

This commit is contained in:
Robin Ward 2016-04-25 12:50:55 -04:00
parent dc014ac4aa
commit 16c44971d9
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
3 changed files with 29 additions and 4 deletions

View File

@ -63,12 +63,16 @@ export default Ember.Component.extend({
afterPatch() {
},
eventDispatched(eventName, key, refreshArg) {
const onRefresh = Ember.String.camelize(eventName.replace(/:/, '-'));
keyDirty(key, { onRefresh, refreshArg });
this.queueRerender();
},
dispatch(eventName, key) {
this._childEvents.push(eventName);
this.appEvents.on(eventName, refreshArg => {
const onRefresh = Ember.String.camelize(eventName.replace(/:/, '-'));
keyDirty(key, { onRefresh, refreshArg });
this.queueRerender();
this.eventDispatched(eventName, key, refreshArg);
});
},

View File

@ -65,6 +65,14 @@ const SiteHeaderComponent = MountWidget.extend({
this.dispatch('notifications:changed', 'user-notifications');
this.dispatch('header:keyboard-trigger', 'header');
this.appEvents.on('dom:clean', () => {
// For performance, only trigger a re-render if any menu panels are visible
if (this.$('.menu-panel').length) {
this.eventDispatched('dom:clean', 'header');
}
});
this.examineDockHeader();
},
@ -78,6 +86,7 @@ const SiteHeaderComponent = MountWidget.extend({
this.appEvents.off('header:show-topic');
this.appEvents.off('header:hide-topic');
this.appEvents.off('dom:clean');
},
buildArgs() {

View File

@ -187,10 +187,14 @@ export default createWidget('header', {
}
},
linkClickedEvent() {
closeAll() {
this.state.userVisible = false;
this.state.hamburgerVisible = false;
this.state.searchVisible = false;
},
linkClickedEvent() {
this.closeAll();
this.updateHighlight();
},
@ -255,6 +259,14 @@ export default createWidget('header', {
this.state.contextEnabled = value;
},
domClean() {
const { state } = this;
if (state.searchVisible || state.hamburgerVisible || state.userVisible) {
this.closeAll();
}
},
headerKeyboardTrigger(msg) {
switch(msg.type) {
case 'search':