From 63dc42cff6b264175e1bba1f9faf90dd14a033c9 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Fri, 2 Jul 2021 13:13:58 +0200 Subject: [PATCH] Do not open autocomplete on clicking input --- ts/components/WithDropdown.svelte | 6 ++++++ ts/editor/WithAutocomplete.svelte | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ts/components/WithDropdown.svelte b/ts/components/WithDropdown.svelte index 9048c9293..801fbae23 100644 --- a/ts/components/WithDropdown.svelte +++ b/ts/components/WithDropdown.svelte @@ -12,6 +12,7 @@ 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 toggleOpen = true; export let drop: "down" | "up" | "left" | "right" = "down"; $: dropClass = `drop${drop}`; @@ -35,6 +36,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /* avoid focusing element toggle on menu activation */ toggle.focus = noop; + if (!toggleOpen) { + /* do not open on clicking toggle */ + toggle.addEventListener = noop; + } + dropdown = new Dropdown(toggle, { autoClose, popperConfig: (defaultConfig: Record) => ({ diff --git a/ts/editor/WithAutocomplete.svelte b/ts/editor/WithAutocomplete.svelte index 1e23857b3..61c0a207f 100644 --- a/ts/editor/WithAutocomplete.svelte +++ b/ts/editor/WithAutocomplete.svelte @@ -122,7 +122,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } - +