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

Allows middle-click and ctrl+click outbound clicks to properly open as user intended #494

Merged
merged 4 commits into from
Dec 22, 2020

Conversation

Vigasaurus
Copy link
Contributor

@Vigasaurus Vigasaurus commented Dec 21, 2020

Changes

Allows middle clicks or ctrl+click, cmd+click, shift+click to track to plausible, and open in a new tab if requested, instead of always redirecting the current tab.

Fixes #451

This will almost certainly cause conflicts with #489 in the compiled script, so I didn't push them in this PR at all. Once both are merged we can re-compile the merged version.

Tests

  • This PR does not require tests

Changelog

  • Entry has been added to changelog

Documentation

  • This change does not need a documentation update

Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way to account for middle clicks as well. Looks like formatting is a bit off and I'm curious what the purpose of window.open is when middle click or modifier is used.

tracker/src/plausible.js Show resolved Hide resolved
tracker/src/plausible.js Outdated Show resolved Hide resolved
@Vigasaurus
Copy link
Contributor Author

Vigasaurus commented Dec 21, 2020

So the reason for using window.open is that browsers interpret middle clicks as "Open in New Tab", the same as ctrl+click or cmd+click - and in the old way we'd always redirect the current tab to the new link. This way ensures that if a user does any of the actions that would normally redirect their click into a new tab (middle click, ctrl+click, cmd+click, or shift+click) - we open a new tab for the link as expected, as opposed to redirecting the current tab.

Nevermind, I see what you meant - we just don't prevent the default for the middle click or mod click. Will fix 👍

Does nothing special on middle or mod-click
@ukutaht ukutaht merged commit 31ed9c0 into plausible:master Dec 22, 2020
oliver-kriska pushed a commit to payout-one/analytics that referenced this pull request Dec 23, 2020
…s user intended (plausible#494)

* Initial fix

* Filesize optimizations

* Changelog

* Only redirects current tab on correct conditions

Does nothing special on middle or mod-click
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

Successfully merging this pull request may close these issues.

Outbound link tracking breaks shortcuts to Open in New Tab
2 participants