UX of copying to clipboard the link to a post

AI-generated summary

The discussion revolves around the UX of copying a link to a post on Discourse. dandv points out that the current process is cumbersome, requiring a left click on the “link” icon, a right click on the link in the popup, and then copying to clipboard.

codinghorror suggests right-clicking the timestamp as an alternative, which dandv confirms works. However, codinghorror notes that right-clicking a “button” is not an expected activity.

The conversation shifts to the possibility of implementing a “copy to clipboard” feature, with DeanMarkTaylor mentioning recent browser support for execCommand('copy'). erlend_sh suggests using the clipboard.js library, which has gained widespread adoption.

The discussion concludes with erlend_sh suggesting that the feature might be better suited as a plugin, and jomaxro sharing a theme that works in Chrome and Firefox, which could potentially be used outside of codeboxes.

Story: desktop user wants to share a link to a post via a channel of their choice.

Right clicking the “link” icon doesn’t work, because the element is a button. The user has to left click the “link” icon, then right click the link in the popup and copy it to clipboard, then close the popup. Slightly cumbersome.

On the other hand, clicking the “link” button does reveal extra actions, so conceptually it should be a button and not an anchor element.

Just putting this UX issue up there for potential discussion.

Possibly, but right clicking the date at the upper right of the post might work, I haven’t checked this in a while. And of course copying the address bar in your browser works as it reflects current position in topic.

The timestamp indeed links to the correct post.

On this very thread, the address bar doesn’t add the /2 to your post because there isn’t sufficient vertical space to scroll down past it and trigger the scroll spy. (Edited out a block of text that artificially increased the “height” of my post).

Yes, right click the timestamp.

I am not sure right clicking a “button” is an expected activity, personally.

Agree, if the button looks like one. The icon looks like… a link :slight_smile:

Just an FYI, the state of “copy to clipboard” has changed - this “might” be useful to improve this feature.

There has recently been support added for execCommand('copy') to Chrome 43+ and upcoming support for Firefox 41 - couple that with existing IE10+ and Opera 29+ that actually seems like “good” browser coverage is coming.

I’ve added a StackOverflow answer to reflect this here with additional reference links and an example:

5 Likes

There’s a new library in town aptly called clipboard.js that seems to be achieving widespread adoption. cc @riking

The demo let me copy text successfully, which is a good sign since I was also experiencing a false “copied to clipboard” message with the first iteration of this feature (Mac OS X 10.10 and Chrome).

5 Likes

Not sure if there is still interest in this; perhaps HTML clipboard standards have evolved since 2015?

3 Likes

Probably plugin territory. clipboard.js is still alive and well so that’s good.

Alternatively those interested in this feature could add Discourse to the clipboard browser extension (primarily for code blocks but they might accept other additions too):

https://github.com/zenorocha/codecopy

This theme worked for me in Chrome and Firefox. If the code can be confirmed in our other supported browsers, it may be able to be used outside of codeboxes:
https://meta.discourse.org/t/copy-option-for-code-blocks-in-discourse/60961

1 Like