From 92324bfb685c7fc6b2f6116a6587a5ffea400317 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 29 Jan 2020 18:28:53 -0500 Subject: [PATCH] [MM-20796] Un-reverted the Ctrl+Tab fix and also made sure the tabs go in the right order (#1173) (#1175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [MM-20796] Un-reverted the Ctrl+Tab fix and also made sure the tabs go in the right order * Style fixes * Update src/browser/components/MainPage.jsx Co-Authored-By: Guillermo Vayá * Different logic Co-authored-by: Guillermo Vayá Co-authored-by: Guillermo Vayá --- src/browser/components/MainPage.jsx | 13 +++++++++++-- src/browser/components/MattermostView.jsx | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/browser/components/MainPage.jsx b/src/browser/components/MainPage.jsx index a7942ee447..2eb20fddec 100644 --- a/src/browser/components/MainPage.jsx +++ b/src/browser/components/MainPage.jsx @@ -159,10 +159,19 @@ export default class MainPage extends React.Component { this.handleSelect(key); }); ipcRenderer.on('select-next-tab', () => { - this.handleSelect(this.state.key + 1); + const currentOrder = this.props.teams[this.state.key].order; + const nextOrder = ((currentOrder + 1) % this.props.teams.length); + const nextIndex = this.props.teams.findIndex((team) => team.order === nextOrder); + this.handleSelect(nextIndex); }); + ipcRenderer.on('select-previous-tab', () => { - this.handleSelect(this.state.key - 1); + const currentOrder = this.props.teams[this.state.key].order; + + // js modulo operator returns a negative number if result is negative, so we have to ensure it's positive + const nextOrder = ((this.props.teams.length + (currentOrder - 1)) % this.props.teams.length); + const nextIndex = this.props.teams.findIndex((team) => team.order === nextOrder); + this.handleSelect(nextIndex); }); // reload the activated tab diff --git a/src/browser/components/MattermostView.jsx b/src/browser/components/MattermostView.jsx index 8e1ec4ab2d..ee328c4611 100644 --- a/src/browser/components/MattermostView.jsx +++ b/src/browser/components/MattermostView.jsx @@ -335,7 +335,7 @@ export default class MattermostView extends React.Component { if (this.props.withTab) { classNames.push('mattermostView-with-tab'); } - if (!this.props.active || this.state.errorInfo) { + if (!this.props.active) { classNames.push('mattermostView-hidden'); }