mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Correctly place dropdown and only update if there's activeInput
This commit is contained in:
parent
9e1f2aa262
commit
18b838a173
2 changed files with 18 additions and 4 deletions
|
@ -11,10 +11,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
export let autoOpen = false;
|
||||
export let autoClose: boolean | "inside" | "outside" = true;
|
||||
|
||||
export let placement = "bottom-start";
|
||||
export let toggleOpen = true;
|
||||
export let drop: "down" | "up" | "left" | "right" = "down";
|
||||
|
||||
let placement: string;
|
||||
$: switch (drop) {
|
||||
case "down":
|
||||
placement = "bottom";
|
||||
break;
|
||||
case "up":
|
||||
placement = "top";
|
||||
break;
|
||||
}
|
||||
|
||||
$: dropClass = `drop${drop}`;
|
||||
|
||||
setContext(dropdownKey, {
|
||||
|
|
|
@ -62,7 +62,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
|
||||
function updateSuggestions(): void {
|
||||
suggestionsPromise = fetchSuggestions(activeName).then(
|
||||
const activeTag = tags[active!];
|
||||
|
||||
suggestionsPromise = fetchSuggestions(activeTag.name).then(
|
||||
(names: string[]): string[] => names.map(replaceWithUnicodeSeparator)
|
||||
);
|
||||
}
|
||||
|
@ -74,11 +76,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
activeInput.setSelectionRange(Infinity, Infinity);
|
||||
}
|
||||
|
||||
function updateTagName(tag: TagType): void {
|
||||
async function updateTagName(tag: TagType): Promise<void> {
|
||||
tag.name = activeName;
|
||||
tags = tags;
|
||||
|
||||
autocomplete.update();
|
||||
await tick();
|
||||
if (activeInput) {
|
||||
autocomplete.update();
|
||||
}
|
||||
}
|
||||
|
||||
function setActiveAfterBlur(value: number): void {
|
||||
|
|
Loading…
Reference in a new issue