Skip to content

Commit

Permalink
[MM-20796] Un-reverted the Ctrl+Tab fix and also made sure the tabs g…
Browse files Browse the repository at this point in the history
…o in the right order (mattermost#1173) (mattermost#1175)

* [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>

Co-authored-by: Guillermo Vayá <guivaya@gmail.com>
  • Loading branch information
devinbinnie and Willyfrog committed Jan 29, 2020
1 parent b82b7ff commit 92324bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/browser/components/MainPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/browser/components/MattermostView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 92324bf

Please sign in to comment.