fix completion navigate

jh-changes
Shin'ya Ueoka 7 years ago
parent aeebdcd3ef
commit 3a1940a0c3
  1. 15
      src/console/components/console.js

@ -13,7 +13,7 @@ export default class ConsoleComponent {
let input = doc.querySelector('#vimvixen-console-command-input'); let input = doc.querySelector('#vimvixen-console-command-input');
input.addEventListener('blur', this.onBlur.bind(this)); input.addEventListener('blur', this.onBlur.bind(this));
input.addEventListener('keydown', this.onKeyDown.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.hideCommand();
this.hideMessage(); this.hideMessage();
@ -49,11 +49,9 @@ export default class ConsoleComponent {
} }
} }
onKeyUp(e) { onInput(e) {
if (e.keyCode === KeyboardEvent.DOM_VK_TAB) { let targetValue = e.target.value;
return; if (targetValue === this.prevValue) {
}
if (e.target.value === this.prevValue) {
return; return;
} }
@ -61,10 +59,10 @@ export default class ConsoleComponent {
let input = doc.querySelector('#vimvixen-console-command-input'); let input = doc.querySelector('#vimvixen-console-command-input');
this.completionOrigin = input.value; this.completionOrigin = input.value;
this.prevValue = e.target.value; this.prevValue = targetValue;
return browser.runtime.sendMessage({ return browser.runtime.sendMessage({
type: messages.CONSOLE_QUERY_COMPLETIONS, type: messages.CONSOLE_QUERY_COMPLETIONS,
text: e.target.value text: targetValue
}).then((completions) => { }).then((completions) => {
this.store.dispatch(consoleActions.setCompletions(completions)); this.store.dispatch(consoleActions.setCompletions(completions));
}); });
@ -110,6 +108,7 @@ export default class ConsoleComponent {
window.focus(); window.focus();
this.prevValue = ''; this.prevValue = '';
this.onInput({ target: input });
} }
hideCommand() { hideCommand() {