Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
10.7k stars 545 forks source link

[BUG] Clicking `Copy to Clipboard` button causes a JavaScript error #542

Closed BHznJNs closed 2 months ago

BHznJNs commented 2 months ago

Describe the bug I tried to run the examples/dash_demo.py, when I opened the Code Export dialog and tried to copy the code with the Copy to Clipboard button, it does not work. When I opened the browser console, it showed a JavaScript error.

To Reproduce

  1. Open Dataset with Pygwalker
  2. Click on the export_code button
  3. Click the Copy to Clipboard button in the Code Export dialog
  4. The copying operation does not work and shows an error in the browser console

Expected behavior Able to copy the code by clicking the Copy to Clipboard button

Screenshots

Clicking the Copy to Clipboard button Clicking the `Copy to Clipboard` button

Shows an JavaScript TypeError in the browser console Shows an JavaScript TypeError in the browser console

Versions

Additional context With the MDN Permissions API docs, I assumes the bug is occured by the implement difference between browsers. In the line 45 of source code file app\src\components\codeExportModal\index.tsx, it used name clipboard-read as PermissionName. In this w3c PR, the clipboard-read permission was removed. In this page, it seems that the clipboard-read field is not in the PermissionName enum for Firefox, while in this page, it seems that the clipboard-read is a non-standard field in the PermissionName enum for Chromium.

longxiaofei commented 2 months ago

Hi, @BHznJNs

Thanks for your feedback.

It seems that there are some bugs when check permissions of clipboard.

If you're willing, you might try to fix it.

Looking forward to your PR.

function name: copyToCliboard
code location: app\src\components\codeExportModal\index.tsx  - line:44