From 3a1940a0c324cbaca85dd50ec1efe23327ec133d Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 30 Oct 2017 20:49:18 +0900 Subject: [PATCH 1/2] fix completion navigate --- src/console/components/console.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/console/components/console.js b/src/console/components/console.js index dcd4041..4a4b66a 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -13,7 +13,7 @@ export default class ConsoleComponent { let input = doc.querySelector('#vimvixen-console-command-input'); input.addEventListener('blur', this.onBlur.bind(this)); input.addEventListener('keydown', this.onKeyDown.bind(this)); - input.addEventListener('keyup', this.onKeyUp.bind(this)); + input.addEventListener('input', this.onInput.bind(this)); this.hideCommand(); this.hideMessage(); @@ -49,11 +49,9 @@ export default class ConsoleComponent { } } - onKeyUp(e) { - if (e.keyCode === KeyboardEvent.DOM_VK_TAB) { - return; - } - if (e.target.value === this.prevValue) { + onInput(e) { + let targetValue = e.target.value; + if (targetValue === this.prevValue) { return; } @@ -61,10 +59,10 @@ export default class ConsoleComponent { let input = doc.querySelector('#vimvixen-console-command-input'); this.completionOrigin = input.value; - this.prevValue = e.target.value; + this.prevValue = targetValue; return browser.runtime.sendMessage({ type: messages.CONSOLE_QUERY_COMPLETIONS, - text: e.target.value + text: targetValue }).then((completions) => { this.store.dispatch(consoleActions.setCompletions(completions)); }); @@ -110,6 +108,7 @@ export default class ConsoleComponent { window.focus(); this.prevValue = ''; + this.onInput({ target: input }); } hideCommand() { From 774a960a835b3f37b36ff69e1b9fcc8975f7c2f0 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 2 Nov 2017 21:04:13 +0900 Subject: [PATCH 2/2] remove comparison with previous value --- src/console/components/console.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/console/components/console.js b/src/console/components/console.js index 4a4b66a..8b69df9 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -4,7 +4,6 @@ import * as consoleActions from 'console/actions/console'; export default class ConsoleComponent { constructor(wrapper, store) { this.wrapper = wrapper; - this.prevValue = ''; this.prevState = {}; this.completionOrigin = ''; this.store = store; @@ -50,19 +49,13 @@ export default class ConsoleComponent { } onInput(e) { - let targetValue = e.target.value; - if (targetValue === this.prevValue) { - return; - } - let doc = this.wrapper.ownerDocument; let input = doc.querySelector('#vimvixen-console-command-input'); this.completionOrigin = input.value; - this.prevValue = targetValue; return browser.runtime.sendMessage({ type: messages.CONSOLE_QUERY_COMPLETIONS, - text: targetValue + text: e.target.value, }).then((completions) => { this.store.dispatch(consoleActions.setCompletions(completions)); }); @@ -107,7 +100,6 @@ export default class ConsoleComponent { input.focus(); window.focus(); - this.prevValue = ''; this.onInput({ target: input }); }