diff --git a/src/lib/actions/clickOutside.ts b/src/lib/actions/clickOutside.ts
new file mode 100644
index 0000000000..8520ac3176
--- /dev/null
+++ b/src/lib/actions/clickOutside.ts
@@ -0,0 +1,15 @@
+export function clickOutside(node: HTMLElement, callback: () => void) {
+ const handleClick = (event: MouseEvent) => {
+ if (node && !node.contains(event.target as Node)) {
+ callback();
+ }
+ };
+
+ document.addEventListener('click', handleClick, true);
+
+ return {
+ destroy() {
+ document.removeEventListener('click', handleClick, true);
+ }
+ };
+}
diff --git a/src/lib/components/Select.svelte b/src/lib/components/Select.svelte
index 7c127fcc72..75fc926904 100644
--- a/src/lib/components/Select.svelte
+++ b/src/lib/components/Select.svelte
@@ -146,14 +146,14 @@
{#each groups as group}
{@const isDefault = group.label === DEFAULT_GROUP}
{#if isDefault}
- {#each options as option}
+ {#each group.options as option}
{/each}
{:else}