Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove clipboardchange event (and replace it possibly with a promise returning method) #228

Open
smaug---- opened this issue Sep 27, 2024 · 1 comment

Comments

@smaug----
Copy link

smaug---- commented Sep 27, 2024

The current definition for clipboardchange event is such that it doesn't work too well with the model Safari and Firefox have (paste requires explicit click on a button).
And if we require always transient user activation before the event, it would be more ergonomic to have something like
element.onclick = () => clipboard.checkCurrentClipboardTypes().then((listOfBuiltinTypes) => { /do something/});

(I'm not saying Firefox would necessarily implement that API, since it is still rather privacy sensitive)

@jyasskin
Copy link
Member

I think your onclick code is just

element.onclick = () => navigator.clipboard.read().then(...);

That is, no change needed if you don't want an event.

I can see an ergonomic improvement from having an event, for pages where the user expects the page to react to every clipboard change, even in the Safari+Firefox model where it only propagates during transient activation. The spec would need to change from

If the clipboard contents are changed outside the user agent, then the clipboardchange event MUST fire when the user agent regains focus.

to something like

If the clipboard contents are changed outside the user agent, then the clipboardchange event MUST fire the next time check clipboard read permission becomes true.

[... with a parallel change to make check clipboard read permission allow the behaviors of all three engines]
[... and that whole statement should probably also be refactored to be more algorithmic.]

Note that, as you said, even with this change the event is somewhat more privacy-invasive than no-event (per #230), since you stop being able to treat pages that read "too often" as potentially abusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants