Correctly place dropdown and only update if there's activeInput

This commit is contained in:
Henrik Giesel 2021-09-08 13:08:56 +02:00
parent 9e1f2aa262
commit 18b838a173
2 changed files with 18 additions and 4 deletions

View file

@ -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, {

View file

@ -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 {