mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Implement autocomplete hiding on empty activeInput + remove logging
This commit is contained in:
parent
392326b863
commit
d3191d7ecb
2 changed files with 11 additions and 21 deletions
|
@ -92,14 +92,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
names.splice(index, 1);
|
||||
|
||||
const contained = names.indexOf(activeName);
|
||||
console.log(
|
||||
"isActiveUnique",
|
||||
active,
|
||||
index,
|
||||
activeName,
|
||||
JSON.stringify(names),
|
||||
contained
|
||||
);
|
||||
if (contained >= 0) {
|
||||
tags[contained >= index ? contained + 1 : contained].flash();
|
||||
return false;
|
||||
|
@ -149,7 +141,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
const deleted = tags.splice(index, 1)[0];
|
||||
tags = tags;
|
||||
|
||||
console.log("dt", activeAfterBlur, index);
|
||||
if (activeAfterBlur !== null && activeAfterBlur > index) {
|
||||
activeAfterBlur--;
|
||||
}
|
||||
|
@ -187,8 +178,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
|
||||
function moveToPreviousTag(index: number): void {
|
||||
console.log("moveprevious", active, index);
|
||||
|
||||
if (isFirst(index)) {
|
||||
return;
|
||||
}
|
||||
|
@ -225,7 +214,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
|
||||
function decideNextActive() {
|
||||
console.log("dna", active, activeAfterBlur);
|
||||
active = activeAfterBlur;
|
||||
activeAfterBlur = null;
|
||||
}
|
||||
|
@ -238,7 +226,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
return event.code === "Backspace" || event.code === "Delete";
|
||||
}
|
||||
|
||||
function update(event: KeyboardEvent, autocomplete: any): void {
|
||||
function onKeydown(event: KeyboardEvent, autocomplete: any): void {
|
||||
const visible = autocomplete.isVisible();
|
||||
const printable = isPrintableKey(event);
|
||||
const deletion = isDeletionKey(event);
|
||||
|
@ -251,10 +239,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
}
|
||||
|
||||
if (activeName.length === 0) {
|
||||
autocomplete.hide();
|
||||
}
|
||||
|
||||
switch (event.code) {
|
||||
case "ArrowUp":
|
||||
autocomplete.selectNext();
|
||||
|
@ -288,6 +272,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onKeyup(_event: KeyboardEvent, autocomplete: any): void {
|
||||
if (activeName.length === 0) {
|
||||
autocomplete.hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<StickyBottom>
|
||||
|
@ -317,7 +307,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
activeName = tag.name;
|
||||
createAutocomplete(activeInput);
|
||||
}}
|
||||
on:keydown={(event) => update(event, autocomplete)}
|
||||
on:keydown={(event) => onKeydown(event, autocomplete)}
|
||||
on:keyup={(event) => onKeyup(event, autocomplete)}
|
||||
on:input={() => updateTagName(tag)}
|
||||
on:tagsplit={({ detail }) =>
|
||||
enterBehavior(
|
||||
|
@ -360,8 +351,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
class="tag-spacer flex-grow-1 align-self-stretch"
|
||||
on:click={appendEmptyTag}
|
||||
/>
|
||||
{active}
|
||||
{activeAfterBlur}
|
||||
</ButtonToolbar>
|
||||
</StickyBottom>
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
function onBlur(event: Event): void {
|
||||
event.preventDefault();
|
||||
|
||||
normalize();
|
||||
console.log("taginput onblur");
|
||||
if (name.length === 0) {
|
||||
dispatch("tagdelete");
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
on:blur={onBlur}
|
||||
on:keydown={onKeydown}
|
||||
on:keydown
|
||||
on:keyup
|
||||
on:input
|
||||
on:paste={onPaste}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue