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

cool#9072 browser: better error handling when navigator.clipboard.write is advertised but fails #9073

Merged
merged 1 commit into from
May 21, 2024

Conversation

vmiklos
Copy link
Contributor

@vmiklos vmiklos commented May 16, 2024

In case an integration doesn't allow clipboard interaction via
https://sdk.collaboraonline.com/docs/advanced_integration.html#allow-the-clipboard-permission-query,
we end up in a situation where navigator.clipboard.write is not
undefined, but is broken.

By the time navigator.clipboard.write() fails, it's too late to fall
back to the old copy code, as the security context is already gone.

Fix the problem by improving the failure handling: show the popup to try
again copying, remember that navigator.clipboard.write() failed and
prefetch the text selection, so next time a copy is tried (via the
keyboard), the selection doesn't need re-creating. (Normally the
selection change would trigger the prefetch, so select->copy->copy-again
would still fail.)

Note that paste doesn't have a similar problem, since there we always
try the old paste code first, and only use the new paste code if the old
one fails.

Signed-off-by: Miklos Vajna [email protected]
Change-Id: I12ea4810395970421000d213744d1838213c7a07

@vmiklos
Copy link
Contributor Author

vmiklos commented May 17, 2024

Rebase to be on top of 873485f

…te is advertised but fails

In case an integration doesn't allow clipboard interaction via
<https://sdk.collaboraonline.com/docs/advanced_integration.html#allow-the-clipboard-permission-query>,
we end up in a situation where navigator.clipboard.write is not
undefined, but is broken.

By the time navigator.clipboard.write() fails, it's too late to fall
back to the old copy code, as the security context is already gone.

Fix the problem by improving the failure handling: show the popup to try
again copying, remember that navigator.clipboard.write() failed and
prefetch the text selection, so next time a copy is tried (via the
keyboard), the selection doesn't need re-creating. (Normally the
selection change would trigger the prefetch, so select->copy->copy-again
would still fail.)

Note that paste doesn't have a similar problem, since there we always
try the old paste code first, and only use the new paste code if the old
one fails.

Signed-off-by: Miklos Vajna <[email protected]>
Change-Id: I12ea4810395970421000d213744d1838213c7a07
@vmiklos
Copy link
Contributor Author

vmiklos commented May 17, 2024

@caolanm could you please review this? Thanks.

#9072 has some details on this, I went the more conservative route and even persist the disable flag in local storage (vs only setting the JS global to false, and try again on next doc edit). This should help with owncloud and other integrations which are left untouched at the moment and would see this as a 23.05 -> 24.04 regression. Nextcloud is not affected, I tested the change with a local revert.

@vmiklos vmiklos requested a review from caolanm May 17, 2024 06:54
@caolanm caolanm merged commit a161ee3 into master May 21, 2024
14 checks passed
@caolanm caolanm deleted the private/vmiklos/master branch May 21, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants