Skip to content

Commit

Permalink
Moving preventDefault down to just before the navigation event
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mr-winter committed Aug 16, 2023
1 parent 6005c5c commit ea59b3c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/routing/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ function LinkInner<TRoute extends AnyRoute>(
onMouseEnter={onMouseEnter ?? _onMouseEnter}
onMouseLeave={onMouseLeave ?? _onMouseLeave}
onClick={(e) => {
e.preventDefault();
if (props.onClick?.(e) === false) {
return;
}
Expand All @@ -108,6 +107,7 @@ function LinkInner<TRoute extends AnyRoute>(
return;
}

e.preventDefault();
to.navigate({ params, query, meta });
}}
>
Expand Down

0 comments on commit ea59b3c

Please sign in to comment.