Disable toggle on clicking element (toggle) for WithAutocomplete

This commit is contained in:
Henrik Giesel 2021-06-29 04:32:54 +02:00
parent bb166392b1
commit e876a374e2
2 changed files with 12 additions and 8 deletions

View File

@ -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;
}
</script>

View File

@ -114,7 +114,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
</script>
<WithDropdownMenu let:menuId let:createDropdown>
<WithDropdownMenu toggleOnClick={false} let:menuId let:createDropdown>
<slot createAutocomplete={createAutocomplete(createDropdown)} {autocomplete} />
<DropdownMenu id={menuId} class={className}>