diff --git a/ts/components/WithDropdownMenu.svelte b/ts/components/WithDropdownMenu.svelte index 14bcec8d0..7d31c1f27 100644 --- a/ts/components/WithDropdownMenu.svelte +++ b/ts/components/WithDropdownMenu.svelte @@ -9,6 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { dropdownKey } from "./contextKeys"; export let disabled = false; + export let toggleOnClick = true; setContext(dropdownKey, { dropdown: true, @@ -41,15 +42,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ); if (!menu) { - console.log(`Could not find menu "${menuId}" for dropdown menu.`); - } else { - dropdown = new Dropdown(element); - - /* Set custom menu without using common element with .dropdown */ - (dropdown as any)._menu = menu; - Object.defineProperty(dropdown, "isVisible", { value: isVisible }); + throw Error(`Could not find menu "${menuId}" for dropdown menu.`); } + if (!toggleOnClick) { + (Dropdown.prototype as any)._addEventListeners = noop; + } + dropdown = new Dropdown(element); + + /* Set custom menu without using common element with .dropdown */ + (dropdown as any)._menu = menu; + Object.defineProperty(dropdown, "isVisible", { value: isVisible }); + return dropdown as Dropdown; } diff --git a/ts/editor/WithAutocomplete.svelte b/ts/editor/WithAutocomplete.svelte index ab24946a9..397f19a81 100644 --- a/ts/editor/WithAutocomplete.svelte +++ b/ts/editor/WithAutocomplete.svelte @@ -114,7 +114,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } - +