Disable toggle on clicking element (toggle) for WithAutocomplete
This commit is contained in:
parent
bb166392b1
commit
e876a374e2
@ -9,6 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
import { dropdownKey } from "./contextKeys";
|
import { dropdownKey } from "./contextKeys";
|
||||||
|
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
|
export let toggleOnClick = true;
|
||||||
|
|
||||||
setContext(dropdownKey, {
|
setContext(dropdownKey, {
|
||||||
dropdown: true,
|
dropdown: true,
|
||||||
@ -41,15 +42,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
console.log(`Could not find menu "${menuId}" for dropdown menu.`);
|
throw Error(`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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return dropdown as Dropdown;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -114,7 +114,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<WithDropdownMenu let:menuId let:createDropdown>
|
<WithDropdownMenu toggleOnClick={false} let:menuId let:createDropdown>
|
||||||
<slot createAutocomplete={createAutocomplete(createDropdown)} {autocomplete} />
|
<slot createAutocomplete={createAutocomplete(createDropdown)} {autocomplete} />
|
||||||
|
|
||||||
<DropdownMenu id={menuId} class={className}>
|
<DropdownMenu id={menuId} class={className}>
|
||||||
|
Loading…
Reference in New Issue
Block a user