From 887fb5ac1a56d50d2f7ab694b8b1e92a2cebc101 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sat, 3 Feb 2018 17:00:30 +0100 Subject: [PATCH] Focus term if needed when restoring (#2658) * Focus term if needed when restoring * Fix Tab component warnings --- lib/components/tab.js | 4 ---- lib/components/term.js | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/components/tab.js b/lib/components/tab.js index 1f2a871d..dbe51c24 100644 --- a/lib/components/tab.js +++ b/lib/components/tab.js @@ -14,10 +14,6 @@ export default class Tab extends PureComponent { }; } - shouldComponentUpdate() { - return true; - } - handleHover() { this.setState({ hovered: true diff --git a/lib/components/term.js b/lib/components/term.js index 312c3ea3..d0e2949a 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -80,6 +80,9 @@ export default class Term extends PureComponent { //We need to set options again after reattaching an existing term Object.keys(this.termOptions).forEach(option => this.term.setOption(option, this.termOptions[option])); } + if (this.props.isTermActive) { + this.term.focus(); + } this.onOpen(this.termOptions); @@ -88,12 +91,7 @@ export default class Term extends PureComponent { } if (props.onActive) { - this.term.on('focus', () => { - // xterm@2 emits this event 2 times. Will be fixed in xterm@3. - if (!this.props.isTermActive) { - props.onActive(); - } - }); + this.term.on('focus', props.onActive); } if (props.onData) {