Skip to content
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

[2.0] Prefetch click triggers visit on secondary button mouseup #2185

Open
ChrisB-TL opened this issue Jan 13, 2025 · 5 comments
Open

[2.0] Prefetch click triggers visit on secondary button mouseup #2185

ChrisB-TL opened this issue Jan 13, 2025 · 5 comments

Comments

@ChrisB-TL
Copy link

Version:

  • @inertiajs/vue3 version: 2.0.0

Describe the problem:

When using prefetch="click", the visit is triggered on mouse up of the secondary mouse button (e.g. user is attempting to access context menu) - making it impossible to e.g. open in new tab without triggering a visit in the current window.

I cannot think of a scenario where the intent behind a secondary button press would be a visit in the same window (i.e. will always be new tab, new window, etc.), so we could probably just ignore any MouseEvent where MouseEvent.button === 2 (or possibly where MouseEvent.button !== 0).

I have only tested w/ Vue3, but it looks like this behavior is common to all adapters.

Steps to reproduce:

<Link href="/" prefetch="click">I shouldn't be visited when clicked with secondary</Link>

@joetannenbaum
Copy link
Contributor

I'm unable to replicate this in v2.0.2 which back ported fixes this these from v1.3.0. Can you confirm this is fixed in the latest version?

@ChrisB-TL
Copy link
Author

Hi Joe

Have upgraded to v2.0.2 and have the same issue. Have noticed in the process of trying to debug, you get the same result when clicking a Link with "select component on page" in Chrome Vue devtools.

I'll try and reproduce in a clean repo and circle back with it if I still get the same.

Cheers

Chris

@ChrisB-TL
Copy link
Author

Hi @joetannenbaum

Have reproduced on the navbar of the welcome page on a fresh install of Breeze (with the nav bar Links changed to prefetch="click").

I've tested on Chrome and Edge, both on Windows. Don't have access to a Mac to check.

Cheers

Chris

@joetannenbaum
Copy link
Contributor

Ok, well, I was unable to replicate it on any scenario on a Mac, I even wrote a Playwright test to safeguard against this behavior and it passed.

But.

I got access to a Windows machine and was able to replicate the behavior it seems. So might take a minute to diagnose what is going on, but at least now I know how to replicate.

@ChrisB-TL
Copy link
Author

Huh! How bizarre. Thanks for looking into Joe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants