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

feature: add ability to copy comment link #981

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

indyteo
Copy link
Contributor

@indyteo indyteo commented Jul 21, 2021

Feature request: Ability to copy comments permalink

As mentioned in the post, it is inspired by GitHub's "Copy Link" feature on comments.

It first add a unique link for each comment, based on their ID.
For example, my reply on this post has the ID #31419, so the link would look like :

https://feedback.fider.io/posts/317/ability-to-copy-comments-permalink#comment-31419

Then, it add the corresponding HTML id attribute on a wrapping div around comments, so the page automatically scroll to the targeted comment.
On the other hand, it also create a highlighted state in the ShowComment component that slightly mutate the comment background (a bit darker than others) to stand out. When a click is performed outside of the comment's area, it get back to normal and the hash is removed from the URL (the part after the #).

Highlighted comment

Finally, an action in the comment's drop down, target the current comment (set the URL in the navigation bar, triggering the comment highlight and scroll), and copy that link into the user's clipboard. A feedback indicate whether the copy was successful or not (due to the lack of support of the Clipboard API by some old outdated browsers), and invite people to manually copy their page's URL if not.

Copy link button

If the hash don't match anything is simply get ignored, and if it looks like a comment reference but we're unable to find it, a notice is shown to the user, because it may happen when the original comment got deleted, or the URL was manually modified and is now invalid. It get instantly cleaned up to avoid further share of a partially invalid link.


I never really played with URL's hash before and found it funny to do this, this is why I decided to train with this idea, even if it only has 2 votes (which means none, except from the submitter and me 😆), and it only took me about an hour so it was fun 😄

@indyteo indyteo changed the title Comment link feature: add ability to copy comment link Jul 21, 2021
@almereyda
Copy link

@indyteo Would you like to rebase this branch on main, or merge it again?

Then we could try to find someone for a review. Eventually you can also request a review?

@indyteo
Copy link
Contributor Author

indyteo commented Oct 26, 2022

Hi @almereyda, I can have a look if it's not much work 👍

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.

None yet

2 participants