From ea59b3cb3447dc4b98acde062b098de8d3b89481 Mon Sep 17 00:00:00 2001 From: Thomas Winter Date: Thu, 17 Aug 2023 11:35:04 +1200 Subject: [PATCH] Moving preventDefault down to just before the navigation event In the onClick event Radix is checking whether the default event was prevented and bails out of doing its things. Since this should just be for preventing the browser from following the link's url, it should be fine to run it just before the navigate call. --- src/routing/Link.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routing/Link.tsx b/src/routing/Link.tsx index 93691c3..82f47e8 100644 --- a/src/routing/Link.tsx +++ b/src/routing/Link.tsx @@ -97,7 +97,6 @@ function LinkInner( onMouseEnter={onMouseEnter ?? _onMouseEnter} onMouseLeave={onMouseLeave ?? _onMouseLeave} onClick={(e) => { - e.preventDefault(); if (props.onClick?.(e) === false) { return; } @@ -108,6 +107,7 @@ function LinkInner( return; } + e.preventDefault(); to.navigate({ params, query, meta }); }} >