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

Unwanted link navigation from LinkTracker #401

Open
zzzzBov opened this issue Oct 26, 2023 · 0 comments
Open

Unwanted link navigation from LinkTracker #401

zzzzBov opened this issue Oct 26, 2023 · 0 comments

Comments

@zzzzBov
Copy link

zzzzBov commented Oct 26, 2023

LinkTracker explicitly causes navigation to occur after tracking, which is fine for most types of links, however there are some circumstances where the link has other behaviors associated with it, and the navigation has already been prevented through preventDefault.

In these cases, LinkTracker will continue to make the link navigate to its location.

Please update the event_handler to also check evt.defaultPrevented before attempting to force a navigation.

As a simple example, the following link should not change the URL when clicked on:

<a href="#" role="button">Example</a>
<script>
document.querySelector('[role="button"]').addEventListener('click', (e) => {
  e.preventDefault();
  // ...other event handling here...
}, false);
</script>
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

1 participant