Refined-github: Copy code feature no longer works

Created on 24 Apr 2018  路  2Comments  路  Source: sindresorhus/refined-github

Referring to the Copy feature implemented by https://github.com/sindresorhus/refined-github/pull/771

Has Github removed / modified their native zeroclipboard feature?

To Replicate:

Try using the copy button in any of the test files in that PR. No text is copied. Example test file, gist file, copy file path

bug help wanted

Most helpful comment

Apparently they changed the implementation, we can probably still use it.

clipboard-copy

All 2 comments

Apparently they changed the implementation, we can probably still use it.

clipboard-copy

I figured out how this new clipboard-copy element works: either it has a value attribute or a for attribute pointing to an element's id, just like <label for="">

This means that we need to create an id on the spot and refer to it. A simple counter would work:

let button = 0;

...

contentToBoCopied.id = contentToBoCopied.id || `rgh-content-${button++}`;

<clipboard-copy for={contentToBoCopied.id}>

However it looks like they haven't added the feedback tooltips yet.

Was this page helpful?
0 / 5 - 0 ratings