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

issue: Return value of handleCopy prop does not get copied to clipboard #268

Open
damnitrahul opened this issue Feb 26, 2021 · 1 comment · May be fixed by #269
Open

issue: Return value of handleCopy prop does not get copied to clipboard #268

damnitrahul opened this issue Feb 26, 2021 · 1 comment · May be fixed by #269

Comments

@damnitrahul
Copy link

Hi,

The return value of handleCopy prop does not get copied to the clipboard.

The docs mention that

function ({ event, dataRenderer, valueRenderer, data, start, end, range }) If set, this function is called whenever the user copies cells. The return string of this function is stored on the clipboard.

but the return value does not get copied automatically.

I looked through the code and found that the copy method is never being called for the return value of the handleCopy prop.

if (this.props.handleCopy) {
            this.props.handleCopy({
              event: e,
              dataRenderer: dataRenderer,
              valueRenderer: valueRenderer,
              data: data,
              start: start,
              end: end,
              range: range,
            });                                 <== The return value is not being copied anywhere. 
          } else {
            var text = range(start.i, end.i)
              .map(function (i) {
                return range(start.j, end.j)
                  .map(function (j) {
                    var cell = data[i][j];
                    var value = dataRenderer ? dataRenderer(cell, i, j) : null;
                    if (
                      value === '' ||
                      value === null ||
                      typeof value === 'undefined'
                    ) {
                      return valueRenderer(cell, i, j);
                    }
                    return value;
                  })
                  .join('\t');
              })
              .join('\n');
            if (window.clipboardData && window.clipboardData.setData) {
              window.clipboardData.setData('Text', text);
            } else {
              e.clipboardData.setData('text/plain', text);
            }
          }
@damnitrahul damnitrahul linked a pull request Mar 2, 2021 that will close this issue
@nadbm
Copy link
Owner

nadbm commented Aug 5, 2021

Sorry this is a problem in the docs rather than the actual method itself. HandleCopy is meant to override any of the default calls.

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 a pull request may close this issue.

2 participants