diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 38be3d3f..190570d4 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -28,9 +28,15 @@ var MainPage = React.createClass({ }, componentDidMount: function() { var thisObj = this; - remote.getCurrentWindow().on('focus', function() { + var focusListener = function() { var webview = document.getElementById('mattermostView' + thisObj.state.key); webview.focus(); + }; + + var currentWindow = remote.getCurrentWindow(); + currentWindow.on('focus', focusListener); + window.addEventListener('beforeunload', function() { + currentWindow.removeListener('focus', focusListener); }); }, handleSelect: function(key) {