website icon indicating copy to clipboard operation
website copied to clipboard

Explain differences and limitations for web apps

Open kevmoo opened this issue 3 years ago • 4 comments

RE https://github.com/flutter/flutter/issues/106046#issuecomment-1172605241

We could take a lot of stuff from the FAQ page: https://docs.flutter.dev/development/platform-integration/web/faq

  • concurrency (compute function in the foundation lib)
  • support for dart:io
  • hot reload
  • Platform.is...

etc

kevmoo avatar Jul 11 '22 21:07 kevmoo

CC @johnpryan

kevmoo avatar Jul 11 '22 21:07 kevmoo

I would prefer that we not include SEO in the list. SEO is not something that other Flutter platforms support, and it's not a fundamental limitation. It's something we just haven't seriously tackled yet.

yjbanov avatar Jul 12 '22 17:07 yjbanov

From https://github.com/flutter/flutter/issues/106046#issuecomment-1172605241 (@ditman)

@Hamdor that's a great suggestion, we have a bunch of issues cut every so often that we can't fix because of how the web platform works (HTTP Responses not working because they're not CORS ready, Image.network, now the clipboard...)

I'll bring this up with the team to see if they have ideas on the best place to document all of this!

atsansone avatar Jun 05 '23 14:06 atsansone

For security reasons, the Clipboard APIs are severely limited when working in a web browser. Here's some documentation:

There's two things that I'm reading in the docs above that are affecting this issue:

  1. The clipboard-write permission is only granted to the currently active tab.
  2. The request to write to the clipboard must be triggered during a user gesture.
  3. (Maybe) Your site needs to be on https.

Number 1 explains why "quickly switching tabs" breaks the ability to copy to the clipboard: your web app is losing the clipboard-write permission that is required by the browser.

Number 2 explains the original issue. When a user gesture "takes too long" to happen, it ends up losing its "special" permissions (being considered a user activation event). This would be similar to attempting to open a URL after a delay, the popup blocker would block the opening of the window (even though it may have been triggered by a user gesture).

I think this article sums it up well, and has some extra info:

  • https://textslashplain.com/2020/05/18/browser-basics-user-gestures

(Closing: this is a browser limitation. If you wrote equivalent code in vanilla JS, you'd have the same issue. There isn't much we can do from Flutter to help!)

atsansone avatar Jun 05 '23 15:06 atsansone