Skip to content

Commit 67667b4

Browse files
committed
fix: Ensure user-provided onclick event in Link component doesn't override internal onclick
1 parent db8eb4f commit 67667b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/Link/Link.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
prependBasePath,
8181
preserveQuery,
8282
children,
83+
onclick: incomingOnclick,
8384
...restProps
8485
}: Props = $props();
8586
@@ -101,10 +102,11 @@
101102
)
102103
);
103104
104-
function handleClick(event: MouseEvent) {
105+
function handleClick(event: MouseEvent & { currentTarget: EventTarget & HTMLAnchorElement }) {
105106
event.preventDefault();
106107
const newState = calculateState(resolvedHash, typeof state === 'function' ? state() : state);
107108
location.goTo(calcHref, { state: newState, replace: calcReplace });
109+
incomingOnclick?.(event);
108110
}
109111
110112
function styleString() {

0 commit comments

Comments
 (0)