diff --git a/ts/components/WithDropdown.svelte b/ts/components/WithDropdown.svelte
index 337072dc7..9048c9293 100644
--- a/ts/components/WithDropdown.svelte
+++ b/ts/components/WithDropdown.svelte
@@ -12,6 +12,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let autoClose: boolean | "inside" | "outside" = true;
export let placement = "bottom-start";
+ export let drop: "down" | "up" | "left" | "right" = "down";
+
+ $: dropClass = `drop${drop}`;
setContext(dropdownKey, {
dropdown: true,
@@ -59,7 +62,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
onDestroy(() => dropdown?.dispose());
-
+
diff --git a/ts/editor/AutocompleteItem.svelte b/ts/editor/AutocompleteItem.svelte
index 576434e25..e4aa61f5e 100644
--- a/ts/editor/AutocompleteItem.svelte
+++ b/ts/editor/AutocompleteItem.svelte
@@ -30,9 +30,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
class:btn-night={nightMode}
class:selected
class:active
+ on:mousedown|preventDefault
on:mouseup
on:mouseenter
- on:mousedown|preventDefault
+ on:mouseleave
>
diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte
index 036337a37..b8c8dd7c6 100644
--- a/ts/editor/TagEditor.svelte
+++ b/ts/editor/TagEditor.svelte
@@ -358,7 +358,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
@@ -395,11 +395,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{#if index === active}
- onAutocomplete(detail.selected)}
+ on:select={({ detail }) => onAutocomplete(detail.selected)}
on:choose={({ detail }) => onChosen(detail.chosen)}
let:createAutocomplete
>
diff --git a/ts/editor/WithAutocomplete.svelte b/ts/editor/WithAutocomplete.svelte
index 14c9f7b94..1e23857b3 100644
--- a/ts/editor/WithAutocomplete.svelte
+++ b/ts/editor/WithAutocomplete.svelte
@@ -14,6 +14,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let className: string = "";
export { className as class };
+ export let drop: "down" | "up" | "left" | "right" = "down";
+
export let suggestionsPromise: Promise;
let target: HTMLElement;
@@ -35,7 +37,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
selected++;
}
- dispatch("autocomplete", { selected: suggestions[selected ?? -1] });
+ dispatch("select", { selected: suggestions[selected ?? -1] });
}
async function selectPrevious() {
@@ -49,7 +51,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
selected--;
}
- dispatch("autocomplete", { selected: suggestions[selected ?? -1] });
+ dispatch("select", { selected: suggestions[selected ?? -1] });
}
async function chooseSelected() {
@@ -100,11 +102,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function setSelected(index: number): void {
selected = index;
+ active = true;
}
- async function chooseIndex(index: number): Promise {
+ function setSelectedAndActive(index: number): void {
+ setSelected(index);
+ }
+
+ async function selectIndex(index: number): Promise {
const suggestions = await suggestionsPromise;
- dispatch("autocomplete", { name: suggestions[index] });
+ active = false;
+ dispatch("select", { selected: suggestions[index] });
}
function selectIfMousedown(event: MouseEvent, index: number): void {
@@ -114,7 +122,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
-
+
@@ -125,9 +133,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
setSelected(index)}
+ on:mousedown={() => setSelectedAndActive(index)}
+ on:mouseup={() => {
+ selectIndex(index);
+ chooseSelected();
+ }}
on:mouseenter={(event) => selectIfMousedown(event, index)}
- on:mouseup={() => chooseIndex(index)}>{suggestion} (active = false)}
+ >{suggestion}
{/each}
{/await}