-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support touchstart
, focus
, blur
events in link prefetch
#2134
base: master
Are you sure you want to change the base?
Conversation
@@ -165,7 +165,7 @@ const Link = forwardRef<unknown, InertiaLinkProps>( | |||
}, prefetchModes) | |||
|
|||
const regularEvents = { | |||
onClick: (event) => { | |||
onClick: (event: Parameters<InertiaLinkProps['onClick']>[0]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit ugly but it's basically reusing the type of the first parameter of the onClick
property defined in InertiaLinkProps
above
click: regularEvents.click, | ||
} | ||
} satisfies ActionEventHandlers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the type assignment with the satisfies
operator to make autocomplete smarter. Now typescript knows which properties from ActionEventHandlers
are defined and which aren't while still validating the types are correct.
@@ -51,11 +51,11 @@ test('can prefetch using link props', async ({ page }) => { | |||
|
|||
await page.getByRole('link', { name: 'On Mount' }).click() | |||
await isPrefetchPage(page, 2) | |||
await expect(requests.requests.length).toBe(0) | |||
expect(requests.requests.length).toBe(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await
s here were not necessary, expect().toBe()
doesn't return a promise, it's all synchronous
4d726f2
to
c9e0aa2
Compare
Add support for
touchstart
,focus
, andblur
events in link prefetchhover
behavior.This is hugely inspired from React Router's link prefetching code. Their event handlers composition is pretty neat too but I don't think it's necessary here.