kit icon indicating copy to clipboard operation
kit copied to clipboard

`clipboard.writeText` doesn't write to clipboard if it's not `string`

Open ramiroaraujo opened this issue 2 years ago • 2 comments

Example:

const num:any = 123
await clipboard.writeText(num)

I know that if correctly typed it will not allow for a non-string to be passed, but I think it should either error out or do a .toString()

ramiroaraujo avatar Sep 26 '23 13:09 ramiroaraujo

I'll fix the internals in the next build like so:

      let text = '';
      if (typeof value === 'number') {
        text = value.toString();
      }

      if (typeof value !== 'string') {
        text = JSON.stringify(value);
      }

      if (text) {
        await clipboard.writeText(text);
      }

johnlindquist avatar Oct 09 '23 20:10 johnlindquist

@ramiroaraujo Can you confirm that this works for you now?

JosXa avatar May 25 '24 14:05 JosXa