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

[Bug] Closing a reddit comment thread redirects to homepage #2412

Closed
namazso opened this issue Sep 19, 2021 · 7 comments · Fixed by #3084
Closed

[Bug] Closing a reddit comment thread redirects to homepage #2412

namazso opened this issue Sep 19, 2021 · 7 comments · Fixed by #3084
Labels
bounty bounty:10$ bug Something isn't working good first issue Good for newcomers type:client-side The user interface of invidious

Comments

@namazso
Copy link
Contributor

namazso commented Sep 19, 2021

Describe the bug
if you click the [-] button next to a reddit comment thread it will redirect you to homepage instead of closing.

Steps to Reproduce

  1. click on [-] on any reddit comment thread
  2. you're redirected to /void(0)

Screenshots
image

@namazso namazso added the bug Something isn't working label Sep 19, 2021
@TheFrenchGhosty
Copy link
Member

void(0) is used to trigger some JS.

For example to open the Reddit comments: you click on "View Reddit comments" that link to "javascript:void(0)"

I'm guessing it's a mistake someone made in the code and instead of "javascript:" it's the instance URL.

@TheFrenchGhosty TheFrenchGhosty added the type:client-side The user interface of invidious label Sep 19, 2021
@unixfox unixfox added the good first issue Good for newcomers label Sep 29, 2021
@TheFrenchGhosty
Copy link
Member

TheFrenchGhosty commented Oct 8, 2021

The problem is that Invidious is serving:

<a href="void(0)" data-onclick="toggle_parent">[ - ]</a>

Even though the line in the code seems correct:

https://github.com/iv-org/invidious/blob/master/src/invidious/comments.cr#L474

Edit: found the issue:

https://github.com/iv-org/invidious/blob/master/src/invidious/comments.cr#L539

@TheFrenchGhosty
Copy link
Member

A 10$ bounty has been added to this issue.

Anyone opening a PR fixing this issue, will receive 10$ (in BTC) from the Invidious project.

More details: #1898

@fristys
Copy link

fristys commented Mar 6, 2022

Can confirm this is still an issue. Any progress on it?

Also, instead of relying on javascript:void(), wouldn't be more sensible to actually use event.preventDefault() somewhere here

e = e.target;
? Or maybe add an extra data- attribute to specify whether the event should be prevented or bubbling should be stopped and then use that in the handlers file?

@TheFrenchGhosty
Copy link
Member

@fristys

Any progress on it?

I don't think so.

Also, instead of relying on javascript:void(), wouldn't be more sensible to actually use event.preventDefault() somewhere here

Maybe? The JS hasn't really ever been changed since no one in the team is a JavaScript developer.

@fristys
Copy link

fristys commented Mar 6, 2022

Also, instead of relying on javascript:void(), wouldn't be more sensible to actually use event.preventDefault() somewhere here

Maybe? The JS hasn't really ever been changed since no one in the team is a JavaScript developer.

Normally, I'd offer my help, but, sadly, at this time my day job doesn't give me a lot of spare time.

I think it's a good practice to use preventDefault / stopImmediatePropagation instead of voids (it'll also save you having to write the whole url thing). It gives you more control over event handling, and a guarantee that native browser events don't get triggered when you don't want them to.

@SamantazFox
Copy link
Member

@fristys yes, in the future I'd like to rewrite all links with data-* attributes and register event handlers in JS.
And as ghosty said, there aren't JS devs in the team, so PRs are much welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty bounty:10$ bug Something isn't working good first issue Good for newcomers type:client-side The user interface of invidious
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants