`event.clipboardData.getData()` does not reflect successful `setData()` call

Confirmed Issue #14110451 • Assigned to Grisha L.

Details

Author
Lucas G.
Created
Oct 6, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
15.15063
Reports
Reported by 7 people

Sign in to watch or report this issue.

Steps to reproduce

Consider the following script:

<script>
  document.addEventListener("copy", function(e) {
    e.clipboardData.setData("text/plain", "plain text");
    console.log(e.clipboardData.getData("text/plain"));
    e.preventDefault();
  });
  function f() {
    document.execCommand("copy");
  }
</script>
<button onclick="f()">Button</button>

The setData() call succeeds, because the string “plain text” actually ends up on the clipboard. However, it is not possible to confirm this, because the getData() call returns an empty string.

Chrome, Safari, and Firefox correctly return the value that setData() sets on e.clipboardData:
https://github.com/lgarron/clipboard.js/blob/v2/test/Conclusions.md#test-results

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “James M.”

      Changed Assigned To to “travil”

      Changed Assigned To from “travil” to “Travis L.”

      Changed Assigned To to “Grisha L.”

      Changed Status to “Confirmed”

    • We have observed the same behaviour when working on Clipboard API integration in CKEditor 4. It is not possible to access the data set in dataTransfer in the same listener in which it was set and as mentioned, empty string is always returned.

      The problem occurs for all accepted MIME types (text/plain, text/html, etc).

      Are there any plans for the fix in the nearest future?

    • The issue is also reproducible in newest Edge version (16.16257).

    You need to sign in to your Microsoft account to add a comment.

    Sign in