Skip to content

Commit

Permalink
Correctly remove resize event listener on terminal unmount
Browse files Browse the repository at this point in the history
Fixes console errors
  • Loading branch information
foot committed Nov 7, 2016
1 parent 2625bb0 commit 127ab41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/app/scripts/components/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Terminal extends React.Component {
this.handleCloseClick = this.handleCloseClick.bind(this);
this.handlePopoutTerminal = this.handlePopoutTerminal.bind(this);
this.handleResize = this.handleResize.bind(this);
this.handleResizeDebounced = _.debounce(this.handleResize, 500);
}

createWebsocket(term) {
Expand Down Expand Up @@ -204,7 +205,7 @@ class Terminal extends React.Component {

const {characterWidth, characterHeight} = terminalCellSize(this.term.element);

window.addEventListener('resize', _.debounce(this.handleResize, 500));
window.addEventListener('resize', this.handleResizeDebounced);

this.resizeTimeout = setTimeout(() => {
this.setState({
Expand All @@ -223,7 +224,7 @@ class Terminal extends React.Component {
clearTimeout(this.reconnectTimeout);
clearTimeout(this.resizeTimeout);

window.removeEventListener('resize', this.handleResize);
window.removeEventListener('resize', this.handleResizeDebounced);

if (this.term) {
log('destroy terminal');
Expand Down

0 comments on commit 127ab41

Please sign in to comment.