copy to clipboard fails on Safari
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17k
- Forks
- 694
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 33
Description
On Safari 16.5.1 copy to clipboard fails. This fails in older releases of flet as well although it worked before, so this appears to be a safari specific issue
Code example to reproduce the issue:
import flet as ft
def test_click(event):
event.page.set_clipboard("Hello World")
def main(page: ft.Page):
t = ft.ElevatedButton(text="Copy to clipboard", on_click=test_click)
page.add(t)
ft.app(target=main, view=ft.WEB_BROWSER)
Describe the results you received:
Safari show an error in the console: copy is not successful NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission
Describe the results you expected:
expect the copy to clipboard to succeed
Additional information you deem important (e.g. issue happens only occasionally):
apparently safari will only allow a copy to clipboard on a user action, not an API call...much like it does not allow opening new tabs. see https://stackoverflow.com/questions/62327358/javascript-clipboard-api-safari-ios-notallowederror-message. This was a iOS only issue but now is done on macOS as well.
Flet version (pip show flet):
0.7.4 and 0.8.1
Operating system:
Additional environment details:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python reproduction with Flet 0.7.4 or 0.8.1 in macOS Safari 16.5.1 and check the reported clipboard error in the browser console. Done means the same user action successfully copies “Hello World” in Safari without the NotAllowedError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100