diff options
author | David Lu <david.lu97@outlook.com> | 2016-08-22 20:36:23 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-08-22 16:36:23 -0800 |
commit | 05f8d138f434141b2a23d29cabaebdbd0482d879 (patch) | |
tree | 3e3a597d9180d6d5e64213cdcc1d150d4806bd9c /webapp/components/sidebar.jsx | |
parent | 80d83ae77c85de5666dc88458e2888f66c49cc90 (diff) | |
download | chat-05f8d138f434141b2a23d29cabaebdbd0482d879.tar.gz chat-05f8d138f434141b2a23d29cabaebdbd0482d879.tar.bz2 chat-05f8d138f434141b2a23d29cabaebdbd0482d879.zip |
PLT-3897 Fixed ALT+UP/DOWN crashing browser (#3848)
* Fixed ALT+UP/DOWN crashing browser
* changed order of return
Diffstat (limited to 'webapp/components/sidebar.jsx')
-rw-r--r-- | webapp/components/sidebar.jsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx index 4c11bb985..354d1f05c 100644 --- a/webapp/components/sidebar.jsx +++ b/webapp/components/sidebar.jsx @@ -65,6 +65,7 @@ export default class Sidebar extends React.Component { this.updateScrollbarOnChannelChange = this.updateScrollbarOnChannelChange.bind(this); this.isLeaving = new Map(); + this.isSwitchingChannel = false; const state = this.getStateFromStores(); state.newChannelModalType = ''; @@ -281,6 +282,12 @@ export default class Sidebar extends React.Component { navigateChannelShortcut(e) { if (e.altKey && !e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) { e.preventDefault(); + + if (this.isSwitchingChannel) { + return; + } + + this.isSwitchingChannel = true; const allChannels = this.getDisplayedChannels(); const curChannelId = this.state.activeId; let curIndex = -1; @@ -299,12 +306,19 @@ export default class Sidebar extends React.Component { nextChannel = allChannels[Utils.mod(nextIndex, allChannels.length)]; ChannelActions.goToChannel(nextChannel); this.updateScrollbarOnChannelChange(nextChannel); + this.isSwitchingChannel = false; } } navigateUnreadChannelShortcut(e) { if (e.altKey && e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) { e.preventDefault(); + + if (this.isSwitchingChannel) { + return; + } + + this.isSwitchingChannel = true; const allChannels = this.getDisplayedChannels(); const curChannelId = this.state.activeId; let curIndex = -1; @@ -333,6 +347,7 @@ export default class Sidebar extends React.Component { nextChannel = allChannels[nextIndex]; ChannelActions.goToChannel(nextChannel); this.updateScrollbarOnChannelChange(nextChannel); + this.isSwitchingChannel = false; } } } |