From d53b2b3fb9d04940597e5d7c628ca169cae40981 Mon Sep 17 00:00:00 2001 From: Derrick Reimer Date: Tue, 25 Jun 2024 21:46:24 -0500 Subject: [PATCH] Fix types and remove use of deprecated browser event prop --- packages/core/src/shouldIntercept.ts | 1 - packages/react/src/Link.ts | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/core/src/shouldIntercept.ts b/packages/core/src/shouldIntercept.ts index c46b9b5c2..42c61fb40 100644 --- a/packages/core/src/shouldIntercept.ts +++ b/packages/core/src/shouldIntercept.ts @@ -3,7 +3,6 @@ export default function shouldIntercept(event: MouseEvent | KeyboardEvent): bool return !( (event.target && (event?.target as HTMLElement).isContentEditable) || event.defaultPrevented || - (isLink && event.which > 1) || (isLink && event.altKey) || (isLink && event.ctrlKey) || (isLink && event.metaKey) || diff --git a/packages/react/src/Link.ts b/packages/react/src/Link.ts index 061b7792c..5d29b01f8 100755 --- a/packages/react/src/Link.ts +++ b/packages/react/src/Link.ts @@ -17,7 +17,7 @@ interface BaseInertiaLinkProps { href: string method?: Method headers?: Record - onClick?: (event: React.MouseEvent) => void + onClick?: (event: React.MouseEvent) => void preserveScroll?: PreserveStateOption preserveState?: PreserveStateOption replace?: boolean @@ -67,10 +67,10 @@ const Link = forwardRef( ref, ) => { const visit = useCallback( - (event) => { + (event: React.MouseEvent) => { onClick(event) - if (shouldIntercept(event)) { + if (shouldIntercept(event.nativeEvent)) { event.preventDefault() router.visit(href, {