flet icon indicating copy to clipboard operation
flet copied to clipboard

Clipboard still not working

Open ndonkoHenri opened this issue 3 years ago • 1 comments

https://flutils.fly.dev/#/ The above link is an app i made with the latest flet version (0.1.62)

But the clipboard is still not working as expected.

Similar issue(already closed): https://github.com/flet-dev/flet/issues/423

ndonkoHenri avatar Oct 17 '22 23:10 ndonkoHenri

I tested on "Shape" tab and it worked, more or less - see a screen recording below. Have to say successful copying to clipboard in safari strongly depends on a latency, i.e. the amount of time between user triggered event (click) and a set clipboard operation. There is a lot of security around that to prevent bots. I'm wondering what we can do to improve reliability.

https://user-images.githubusercontent.com/5041459/196304780-b5e7610f-868a-4f8f-9c4a-4864d98c9c9d.mp4

FeodorFitsner avatar Oct 17 '22 23:10 FeodorFitsner

So, I noticed just now that while testing the clipboard last time my Safari browser was in private mode. Maybe that caused nothing to enter my clipboard.

What I can say now is, the clipboard is working but with a very straaange behavior.

Have a look at what I got.

https://user-images.githubusercontent.com/98978078/196394920-8bd70add-0c02-402c-953d-b1080e3fefd5.MOV

It worked normally for the first tries but after that ...seems like nothing enters anymore.

To be mentioned:

  • on other browsers (chrome, brave) it works once in a while.

  • there is issue (that you also had in your device), leaving the app for just some seconds shows up a "reconnection screen". Why is it like that, and eventually could it be solved? (Such a behavior is really annoying und also uncommon.)

ndonkoHenri avatar Oct 18 '22 09:10 ndonkoHenri

I'm thinking... it's not ideal of course, but could it be a solution if we move setting value to a clipboard to a client (Flutter) side, kind of:

ElevatedButton("Copy value", set_clipboard="some data")

Clipboard is seriously jammed in Safari: https://github.com/flutter/flutter/issues/106046 https://stackoverflow.com/questions/70179363/navigator-clipboard-copy-doesnt-work-on-safari-when-the-copy-text-is-grabbed-via

FeodorFitsner avatar Oct 19 '22 02:10 FeodorFitsner

I don't really know if this new approach will work best/as expected.

Maybe you could create a new branch, add it to one or two controls, and let's give it a try. Who knows?

ndonkoHenri avatar Oct 19 '22 09:10 ndonkoHenri

Will you try it out @FeodorFitsner ?

ndonkoHenri avatar Oct 21 '22 18:10 ndonkoHenri

Deploying a flet app(ex) as a static site (with the help of pyodide) seems to make the copy functionality work (on iOS) as expected and solves this issue.

Only web app deploy is left to 'fully' conquer.

ndonkoHenri avatar Feb 02 '23 02:02 ndonkoHenri

it's how Safari behaves. When everything is running in a browser the delay between "user gesture" (click on a button) and the call to a clipboard operation is minimal, so Safari believes that it was a user who initiated clipboard update. When Python is running on a server there is a longer delay which is considered by Safari as "insecure", it thinks that it's a bot/script that tries to access the clipboard.

FeodorFitsner avatar Feb 04 '23 22:02 FeodorFitsner

Oh I see. Thanks for briefing. Should we close this issue ?

ndonkoHenri avatar Feb 04 '23 23:02 ndonkoHenri

Yep, closing.

FeodorFitsner avatar Feb 04 '23 23:02 FeodorFitsner