From bbafd8c2d33db1779f9c61577f6b8a23fcabfe11 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Dec 2018 15:22:02 +0100 Subject: [PATCH] toggle right panel when clicking already active header button --- .../views/right_panel/HeaderButton.js | 1 + .../views/right_panel/HeaderButtons.js | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/views/right_panel/HeaderButton.js b/src/components/views/right_panel/HeaderButton.js index a01d3444f1..bb9f613607 100644 --- a/src/components/views/right_panel/HeaderButton.js +++ b/src/components/views/right_panel/HeaderButton.js @@ -36,6 +36,7 @@ export default class HeaderButton extends React.Component { dis.dispatch({ action: 'view_right_panel_phase', phase: this.props.clickPhase, + fromHeader: true, }); } diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 3c59c52089..16f7f006f8 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -49,9 +49,24 @@ export default class HeaderButtons extends React.Component { onAction(payload) { if (payload.action === "view_right_panel_phase") { - this.setState({ - phase: payload.phase, - }); + // only actions coming from header buttons should collapse the right panel + if (this.state.phase === payload.phase && payload.fromHeader) { + dis.dispatch({ + action: 'hide_right_panel', + }); + this.setState({ + phase: null, + }); + } else { + if (!this.state.phase) { + dis.dispatch({ + action: 'show_right_panel', + }); + } + this.setState({ + phase: payload.phase, + }); + } } }