Invert if
This commit is contained in:
parent
6fcd555493
commit
e708cd5d0e
@ -44,22 +44,25 @@ function load(text: String) {
|
||||
});
|
||||
};
|
||||
function keypress(e: KeyboardEvent) {
|
||||
if (e.key == "Enter") {
|
||||
const selected = Suggestions.value[0];
|
||||
selectElement(selected);
|
||||
const el = (<HTMLInputElement>e.target);
|
||||
const inputElements = Array.from(el.ownerDocument.querySelectorAll('input:not([disabled]):not([readonly])'));
|
||||
const currentIndex = inputElements.indexOf(el);
|
||||
const nextElement = inputElements[currentIndex < inputElements.length - 1 ? currentIndex + 1 : 0];
|
||||
(<HTMLInputElement>nextElement).focus();
|
||||
}
|
||||
if (e.key != "Enter")
|
||||
return;
|
||||
|
||||
const selected = Suggestions.value[0];
|
||||
selectElement(selected);
|
||||
const el = (<HTMLInputElement>e.target);
|
||||
const inputElements = Array.from(el.ownerDocument.querySelectorAll('input:not([disabled]):not([readonly])'));
|
||||
const currentIndex = inputElements.indexOf(el);
|
||||
const nextElement = inputElements[currentIndex < inputElements.length - 1 ? currentIndex + 1 : 0];
|
||||
(<HTMLInputElement>nextElement).focus();
|
||||
};
|
||||
|
||||
function selectElement(element: Suggestion) {
|
||||
emit('update:id', element.ID);
|
||||
emit('update:text', element.Name);
|
||||
emit('update:type', element.Type);
|
||||
Suggestions.value = [];
|
||||
};
|
||||
|
||||
function select(e: MouseEvent) {
|
||||
const target = (<HTMLInputElement>e.target);
|
||||
const valueAttribute = target.attributes.getNamedItem("value");
|
||||
@ -69,6 +72,7 @@ function select(e: MouseEvent) {
|
||||
const selected = Suggestions.value.filter(x => x.ID == selectedID)[0];
|
||||
selectElement(selected);
|
||||
};
|
||||
|
||||
function clear() {
|
||||
emit('update:id', null);
|
||||
emit('update:text', SearchQuery.value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user