[MM-20796] Un-reverted the Ctrl+Tab fix and also made sure the tabs go in the right order (#1173)

* [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á <guivaya@gmail.com>

* Different logic

Co-authored-by: Guillermo Vayá <guivaya@gmail.com>
This commit is contained in:
Devin Binnie
2020-01-29 18:02:19 -05:00
committed by GitHub
parent 59f2a02c36
commit 6551483db7
2 changed files with 12 additions and 3 deletions

View File

@@ -156,10 +156,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

View File

@@ -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');
}