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

Automated events prevent links from opening #51

Open
pavish opened this issue Jan 30, 2025 · 1 comment
Open

Automated events prevent links from opening #51

pavish opened this issue Jan 30, 2025 · 1 comment

Comments

@pavish
Copy link

pavish commented Jan 30, 2025

We have automated events enabled in our website mathesar.org.

I noticed that the anchor buttons don't seem to perform navigation on our site in UAE, where I'm currently residing. This is because the click events are prevented, and the navigation is assigned to a callback which happens only when the event is sent i.e when the image 'simple.gif' loads or if an error is thrown, both of which don't seem to be triggering the callback.

Here's an issue in our repo with more details: mathesar-foundation/mathesar-website#127

Update:

Strike my initial reasoning, I went through the auto-events code and found this:

      var callback = function () {
        if (!sent && !element.hasAttribute("target"))
          document.location = element.getAttribute("href");
        sent = true;
      };

The anchor links in our site, had target attributes for _self.

<a ... target="_self" href="...">

This prevented the callback from being called, since they had a target attribute.

And since the onClick event returns false, chrome did not navigate to the href. Somehow, some versions of Firefox seemed to work.

@adriaandotcom
Copy link
Collaborator

Thanks! Is it expected behaviour to always return true for these onClick handlers?

We can fix this in two ways:

  1. Return true for Simple Analytics' onClick handler
  2. Test for if (!sent && element.getAttribute("target") !== "_blank")

What do you think is best?

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