Skip to content

Clipboard.write() - only supports writing one ClipboardItem on Chrome/FF - #30507

Open
hamishwillee wants to merge 1 commit into
mdn:mainfrom
hamishwillee:ff156_clipboard_write_one_clipboarditem
Open

hamishwillee wants to merge 1 commit into
mdn:mainfrom
hamishwillee:ff156_clipboard_write_one_clipboarditem

Conversation

@hamishwillee

@hamishwillee hamishwillee commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Chrome and FF only support writing one ClipboardItem - tested using (async (i = (t) => new ClipboardItem({ "text/plain": t })) => navigator.clipboard.write([i("a"), i("b")]).then(() => "resolved", (e) => ${e.name}: ${e.message}))().
Safari allows writing as many as you like.

The spec says that you may write more than one item if the OS supports it but that if not only the first item may be writen.

But what happens on Chrome/FF is a NotAllowedError exception - the spec says that additional items should be ignored.

(async (i = (t) => new ClipboardItem({ "text/plain": t })) => navigator.clipboard.write([i("a"), i("b")]).then(() => "resolved", (e) => `${e.name}: ${e.message}`))()

Promise { <state>: "fulfilled", <value>: "NotAllowedError: Clipboard write is only supported with one ClipboardItem at the moment" }

I added this as a note, but wondering if it should be a subfeature or this is OK? (or something else)

Related docs work can be tracked in mdn/content#45430

@github-actions github-actions Bot added data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API size:s Pull request changing 7-24 lines of code. labels Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

Comment thread api/Clipboard.json
"From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.",
"Before version 107, the user must grant the `clipboard-write` permission."
"Before version 107, the user must grant the `clipboard-write` permission.",
"Only supports writing one `ClipboardItem`."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a bug we could reference?

Could we mention what happens when writing more than one (NotAllowedError)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API size:s Pull request changing 7-24 lines of code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants