From 52a8f8e0e775558641ab93d9c93a3f8e5e6288b1 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Fri, 26 Jul 2019 15:50:07 +0000 Subject: [PATCH] Bug 1569187 - Move blur event listeners outside of JSTerm. r=jdescottes. Differential Revision: https://phabricator.services.mozilla.com/D39510 --HG-- extra : moz-landing-system : lando --- devtools/client/webconsole/components/App.js | 9 +++++++++ .../client/webconsole/components/Input/JSTerm.js | 16 ---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/devtools/client/webconsole/components/App.js b/devtools/client/webconsole/components/App.js index a038614f5e4c..ae181712af8d 100644 --- a/devtools/client/webconsole/components/App.js +++ b/devtools/client/webconsole/components/App.js @@ -101,6 +101,15 @@ class App extends Component { this.onClick = this.onClick.bind(this); this.onPaste = this.onPaste.bind(this); this.onKeyDown = this.onKeyDown.bind(this); + this.onBlur = this.onBlur.bind(this); + } + + componentDidMount() { + window.addEventListener("blur", this.onBlur); + } + + onBlur() { + this.props.dispatch(actions.autocompleteClear()); } onKeyDown(event) { diff --git a/devtools/client/webconsole/components/Input/JSTerm.js b/devtools/client/webconsole/components/Input/JSTerm.js index 24db75cfd966..6a2b19fa07c6 100644 --- a/devtools/client/webconsole/components/Input/JSTerm.js +++ b/devtools/client/webconsole/components/Input/JSTerm.js @@ -124,7 +124,6 @@ class JSTerm extends Component { this._keyPress = this._keyPress.bind(this); this._inputEventHandler = this._inputEventHandler.bind(this); - this._blurEventHandler = this._blurEventHandler.bind(this); this.onContextMenu = this.onContextMenu.bind(this); this.imperativeUpdate = this.imperativeUpdate.bind(this); @@ -507,7 +506,6 @@ class JSTerm extends Component { ? null : this._getInputPaddingInlineStart(); - this.webConsoleUI.window.addEventListener("blur", this._blurEventHandler); this.lastInputValue && this._setValue(this.lastInputValue); } @@ -951,16 +949,6 @@ class JSTerm extends Component { } } - /** - * The window "blur" event handler. - * @private - */ - _blurEventHandler() { - if (this.autocompletePopup) { - this.clearCompletion(); - } - } - /* eslint-disable complexity */ /** * The inputNode "keypress" event handler. @@ -1739,10 +1727,6 @@ class JSTerm extends Component { this.inputNode.removeEventListener("keypress", this._keyPress); this.inputNode.removeEventListener("input", this._inputEventHandler); this.inputNode.removeEventListener("keyup", this._inputEventHandler); - this.webConsoleUI.window.removeEventListener( - "blur", - this._blurEventHandler - ); } if (this.editor) {