mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -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 autoOpen = false;
|
||||||
export let autoClose: boolean | "inside" | "outside" = true;
|
export let autoClose: boolean | "inside" | "outside" = true;
|
||||||
|
|
||||||
export let placement = "bottom-start";
|
|
||||||
export let toggleOpen = true;
|
export let toggleOpen = true;
|
||||||
export let drop: "down" | "up" | "left" | "right" = "down";
|
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}`;
|
$: dropClass = `drop${drop}`;
|
||||||
|
|
||||||
setContext(dropdownKey, {
|
setContext(dropdownKey, {
|
||||||
|
|
|
@ -62,7 +62,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSuggestions(): void {
|
function updateSuggestions(): void {
|
||||||
suggestionsPromise = fetchSuggestions(activeName).then(
|
const activeTag = tags[active!];
|
||||||
|
|
||||||
|
suggestionsPromise = fetchSuggestions(activeTag.name).then(
|
||||||
(names: string[]): string[] => names.map(replaceWithUnicodeSeparator)
|
(names: string[]): string[] => names.map(replaceWithUnicodeSeparator)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +76,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
activeInput.setSelectionRange(Infinity, Infinity);
|
activeInput.setSelectionRange(Infinity, Infinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTagName(tag: TagType): void {
|
async function updateTagName(tag: TagType): Promise<void> {
|
||||||
tag.name = activeName;
|
tag.name = activeName;
|
||||||
tags = tags;
|
tags = tags;
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
if (activeInput) {
|
||||||
autocomplete.update();
|
autocomplete.update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setActiveAfterBlur(value: number): void {
|
function setActiveAfterBlur(value: number): void {
|
||||||
if (activeAfterBlur === null) {
|
if (activeAfterBlur === null) {
|
||||||
|
|
Loading…
Reference in a new issue