[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:
@@ -156,10 +156,19 @@ export default class MainPage extends React.Component {
|
|||||||
this.handleSelect(key);
|
this.handleSelect(key);
|
||||||
});
|
});
|
||||||
ipcRenderer.on('select-next-tab', () => {
|
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', () => {
|
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
|
// reload the activated tab
|
||||||
|
@@ -335,7 +335,7 @@ export default class MattermostView extends React.Component {
|
|||||||
if (this.props.withTab) {
|
if (this.props.withTab) {
|
||||||
classNames.push('mattermostView-with-tab');
|
classNames.push('mattermostView-with-tab');
|
||||||
}
|
}
|
||||||
if (!this.props.active || this.state.errorInfo) {
|
if (!this.props.active) {
|
||||||
classNames.push('mattermostView-hidden');
|
classNames.push('mattermostView-hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user