From 76be8830909ee0fb7ebf6dc5fbd9fde0d7ca9e51 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 11 Feb 2024 12:39:15 -0800
Subject: feat(layout): prevent default on dropdown

---
 src/lib/Dropdown.svelte | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/lib/Dropdown.svelte')

diff --git a/src/lib/Dropdown.svelte b/src/lib/Dropdown.svelte
index bd657f9a..39d9ecec 100644
--- a/src/lib/Dropdown.svelte
+++ b/src/lib/Dropdown.svelte
@@ -3,6 +3,7 @@
 		name: string;
 		url: string;
 		onClick?: () => void;
+		preventDefault?: boolean;
 	}
 
 	export let items: Item[] = [];
@@ -43,7 +44,14 @@
 
 	<div class={`dropdown-content card card-small ${open ? 'dropdown-open' : ''}`}>
 		{#each items as item}
-			<a href={item.url} class="header-item" on:click={item.onClick}>
+			<a
+				href={item.url}
+				class="header-item"
+				on:click={(e) => {
+					if (item.preventDefault) e.preventDefault();
+					if (item.onClick) item.onClick();
+				}}
+			>
 				{item.name}
 			</a>
 		{/each}
-- 
cgit v1.2.3

