Server: »Share via link« should automatically copy the link to the clipboard

Created on 1 Jul 2016  Â·  16Comments  Â·  Source: nextcloud/server

(In the sharing section of the sidebar.) That will make the sharing flow a lot easier.

2. developing design enhancement sharing medium

Most helpful comment

Peek 10-07-2019 14-55

All 16 comments

Were do you want to hook in? I'm about to create a PR but I'm not familiar with the coding style. I checked the code and thought about adding a function to the this.model.on('change:linkShare',..) callback or even into the render function. https://github.com/nextcloud/server/blob/master/core/js/sharedialoglinkshareview.js#108

cc @schiessle and @MorrisJobke for input on @go2sh's question. :)

As far as I could see (was playing the whole day with this issue), your proposed hook is the only way to go @go2sh . I can grab the link in the shareitem model, but a) I'd rather not have displaying stuff in the model code and b) I was not able to select the text for copying.
Unfortunately I am stuck here. I wanted to use the commandExecute('copy') function, but it seems to be allowed only after a user-generated event.
What would be the way to go here?

There is anouter commandExecute('selectAll'). As far as I understand the docs, it selects all text in an editable region. This should solve the selecting problem. So the following could be done:

  • Let the render finish
  • Focus the text field
  • commandExecute('selectAll')
  • commandExecute('copy')

Alternative there is a jquery function called .select() which should select all text as the jquery docs show https://api.jquery.com/select/.

I'll try to write a small function tomorrow and if it works, I'll create a PR where the rest can be discussed.

Btw. Part of the code is already there as the text field has a onLinkTextClick event handler which creates the focus and selects the text. :-)

I was done with that too plus the autocopy. I though about automatically copying it to clipboard. It might erase content, that the user is not are of. Then you are never able to share a link without thinking about your clipboard. I guess clicking on another button is also acceptable. But I don't mind. Should I submit a PR or do you want to include upstream?

I think we should wait for https://github.com/owncloud/core/pull/25418 indeed. I do not want autocopy. I should have control over my own clipboard.

Ok so the clipboard thingy is in. Not the autocopy. I still think that is a bad idea.

Ref https://github.com/nextcloud/server/issues/1273 also for the same thing on local link.

@rullzer good point with that it’s not possible on OS X.

It now also works with Safari.

Anyway the "copy" function is now part of the share section:
image

The last point to decide is whether to auto copy or not.
I can understand both sides:
Control over your clipboard ↔ convenience

So, what should we do here @nextcloud/designers

@weeman1337 actually the actual code is already supposed to do that, but is broken because the click is triggered before the render (time for the enable public share request to complete)

https://github.com/nextcloud/server/blob/c435bfe703cd2cd059e478cc381d7249038c04e6/core/js/sharedialoglinkshareview.js#L297-L298
I have a pending fix for that: https://github.com/nextcloud/server/compare/public-share-link-menu-copy

But I really dislike what I did, shady javascript scripts to ensure the element is present. :/

The last point to decide is whether to auto copy or not.
I can understand both sides:
Control over your clipboard ↔ convenience

You create a share link, and that mostly means you want to share it. Also, the label literally says "Share link", so you could argue that copying to the clipboard is perfectly normal.

Convenience definitely is more important in this case. This is another of these cases like catching Ctrl-F for our search field, Ctrl-S for saving where lots of people initially disagreed but it just works so well. We are here to make lives easier for regular people, so this is what we do.

Peek 10-07-2019 14-55

@skjnldsv :rocket: :tada:

Was this page helpful?
0 / 5 - 0 ratings