Skip to content

Fix copy command - #3290

Merged
texodus merged 1 commit into
masterfrom
clipboard-api-update
Nov 13, 2026
Merged

texodus merged 1 commit into
masterfrom
clipboard-api-update

Conversation

@texodus

@texodus texodus commented Nov 13, 2026

Copy link
Copy Markdown
Member

This PR fixes a bug in the design of <perspective-viewer>'s copy API. viewer.copy() and the copy menus in the status bar and panel menu did not write the clipboard until the export had finished (a timer polled for the result and then called clipboard.write). That happens outside the user gesture, which Safari can reject. Also, the write's promise was also discarded, so copy() resolved even when the write was denied. If the export failed, the timer leaked. Modified:

  • copy_to_clipboard now calls navigator.clipboard.write before returning, passing a ClipboardItem whose value is aPromise for the exported data. The returned future rejects if the Clipboard API is missing, if the export fails, or if the write is denied.
  • export_method_to_blob now reads the selection when it is called, not when the export first runs.
  • Clicking a panel's body activates it. The frame's Yew onpointerdown never fired for plugins, because Yew's event handling does not follow slot assignment. It is replaced by a plain pointerdown listener on the viewer element, matching the existing contextmenu listener.
  • copy({ method: "plugin" }) on a chart now writes image/png (it was labelled the PNG text/plain).

Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus texodus added the bug Concrete, reproducible bugs label Nov 13, 2026
@texodus
texodus merged commit 56038ac into master Nov 13, 2026
19 checks passed
@texodus
texodus deleted the clipboard-api-update branch November 13, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Concrete, reproducible bugs

Development

Successfully merging this pull request may close these issues.

1 participant