Do not open autocomplete on clicking input

This commit is contained in:
Henrik Giesel 2021-07-02 13:13:58 +02:00
parent 95806c5176
commit 63dc42cff6
2 changed files with 7 additions and 1 deletions

View File

@ -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<string, any>) => ({

View File

@ -122,7 +122,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
</script>
<WithDropdown {drop} let:createDropdown>
<WithDropdown {drop} toggleOpen={false} let:createDropdown>
<slot createAutocomplete={createAutocomplete(createDropdown)} />
<DropdownMenu class={className}>