From 46173019cd8cfd53dbdf5d150a29b0a2b9eacf79 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Mon, 18 Sep 2017 22:13:45 +0200 Subject: [PATCH] Prevent xterm to emit focus event twice --- lib/components/term.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/components/term.js b/lib/components/term.js index f8c6900c..eaca996d 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -55,7 +55,12 @@ export default class Term extends PureComponent { } if (props.onActive) { - this.term.on('focus', 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(); + } + }); } if (props.onData) {