Skip to content

Clipboard Write canvas content to clipboard example not working in safari #39174

Closed
@Guy-HiveIT

Description

@Guy-HiveIT

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write

What specific section or headline is this issue about?

Write canvas contents to the clipboard

What information was incorrect, unhelpful, or incomplete?

The example for copying canvas content to clipboard does not work on Safari (presumably on iOS too but I have only been able to test on a macbook).

I get a console error when clicking the blue square - or actually two different error messages. Firstly:
Unhandled Promise Rejection: TypeError: ClipboardItem.supports is not a function. (In 'ClipboardItem.supports("image/png")', 'ClipboardItem.supports' is undefined)
and then if I remove the supports check I get another error:
NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

There was never a prompt to allow permission.

What did you expect to see?

The blue square would be copied to clipboard successfully

Do you have any supporting links, references, or citations?

I have found various articles/blogs relating to copying to clipboard on safari and seem to indicate that when instantiating a new ClipboardItem, Safari only works if the blob is resolved from a promise. But I have not been able to replicate this successfully.
new ClipboardItem({ [blob.type]: blob })

Some related links below:

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions