[w3c/clipboard-apis] `changeId` interaction between `clipboard.write` and `clipboardchange` (Issue #243)

jamiewalch created an issue (w3c/clipboard-apis#243)

If a site updates the clipboard via `clipboard.write()`, it can't use `changeId` to detect the resultant `clipboardchange` event because the `changeId` isn't available before the `clipboardchange` event is received. This can lead to some bad behavior in remote desktop applications:

* User copies rich text to the clipboard on the host (remote) machine
* Host supports only plain text, so sends that to the client (local) website
* Client updates the clipboard with the plain text
* Browser fires `clipboardchange`
* Client, not having a `changeId` against which to de-duplicate, sends the plain text back to the host
* Host overwrites the rich text clipboard with the plain text one

This can be fixed by checking the clipboard contents, but the whole point of `changeId` is to provide a fast "I already know about this clipboard" check. I can think of a few solutions that avoid checking the contents:

* Don't deliver `clipboardchange` events for self-initiated clipboard writes
* Use a sentinel `changeId` value for self-initiated clipboard writes
* Make `changeId` accessible via `navigator.clipboard`

The first two have the advantage that they only need changes to the `clipboardchange` spec, which isn't finalized yet.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/243
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/issues/243@github.com>

Received on Wednesday, 1 October 2025 21:03:59 UTC