Skip to content

Commit

Permalink
Fix types and remove use of deprecated browser event prop (#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer authored Jun 28, 2024
1 parent 3a63529 commit dedc932
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/core/src/shouldIntercept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface BaseInertiaLinkProps {
href: string
method?: Method
headers?: Record<string, string>
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void
onClick?: (event: React.MouseEvent<Element>) => void
preserveScroll?: PreserveStateOption
preserveState?: PreserveStateOption
replace?: boolean
Expand Down Expand Up @@ -67,10 +67,10 @@ const Link = forwardRef<unknown, InertiaLinkProps>(
ref,
) => {
const visit = useCallback(
(event) => {
(event: React.MouseEvent) => {
onClick(event)

if (shouldIntercept(event)) {
if (shouldIntercept(event.nativeEvent)) {
event.preventDefault()

router.visit(href, {
Expand Down

0 comments on commit dedc932

Please sign in to comment.