From 05f8d138f434141b2a23d29cabaebdbd0482d879 Mon Sep 17 00:00:00 2001 From: David Lu Date: Mon, 22 Aug 2016 20:36:23 -0400 Subject: PLT-3897 Fixed ALT+UP/DOWN crashing browser (#3848) * Fixed ALT+UP/DOWN crashing browser * changed order of return --- webapp/components/sidebar.jsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'webapp') 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; } } } -- cgit v1.2.3-1-g7c22