Author Topic: v11.1.0 Ctrl-C throws an error  (Read 525 times)

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 78
    • View Profile
v11.1.0 Ctrl-C throws an error
« on: June 05, 2026, 05:07:57 pm »
Hi Paramvir, I'm upgrading my grids to the latest version (v11.1.0) but it no longer performs copy with Ctrl-C.  It's throwing the following error...

pqgrid.min.js:13 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'write')
    at Object.copy (pqgrid.min.js:13:97225)
copy @ pqgrid.min.js:13
await in copy
copy @ pqgrid.min.js:13
onCopy @ pqgrid.min.js:13
(anonymous) @ pqgrid.min.js:13

Paste with Ctrl-V is working ok, but only with data previously in the clipboard.  Nothing new gets added with Ctrl-C.



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6552
    • View Profile
Re: v11.1.0 Ctrl-C throws an error
« Reply #1 on: June 05, 2026, 05:38:31 pm »
Copy and paste functionality in recent versions of ParamQuery Grid relies on the modern
Code: [Select]
navigator.clipboard API. The error "Cannot read properties of undefined (reading 'write')" explicitly indicates that the browser is blocking access to this API.

To resolve this issue, please ensure the following environment requirements are met:

  • Use HTTPS or Localhost: Modern browsers restrict the Clipboard API strictly to Secure Contexts. The
Code: [Select]
navigator.clipboard object will be undefined if your application is running over standard
Code: [Select]
http:// on a remote server or IP address. It will only function over
Code: [Select]
https:// or
Code: [Select]
http://localhost
    for local development.
  • Keep Document Focus: The browser requires active page focus to modify the clipboard. If your cursor or focus is currently inside the Browser Developer Tools (Console/Elements panel) while you press Ctrl+C, the operation will fail. Make sure to click inside the grid cells before testing the shortcut.
« Last Edit: June 05, 2026, 06:06:01 pm by paramvir »

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 78
    • View Profile
Re: v11.1.0 Ctrl-C throws an error
« Reply #2 on: June 05, 2026, 06:33:16 pm »
Understood.  I'm using http in a local site environment but from a different server so I don't think I can use localhost.

Are you planning a workaround to allow this in future or are we now locked into https requirement?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6552
    • View Profile
Re: v11.1.0 Ctrl-C throws an error
« Reply #3 on: June 05, 2026, 10:18:02 pm »
Because this security restriction is enforced directly by the browser engine (Chromium, WebKit, Gecko) rather than the grid framework, it is unfortunately impossible to implement a workaround within the software itself. If the site is served over
Code: [Select]
http:// (and is not localhost), the browser completely removes the
Code: [Select]
navigator.clipboard object from the global window scope for security reasons.

However, since you are in a local development/testing environment, you can easily bypass this browser restriction using one of the following solutions:

Solution 1: Enable the Insecure Origin Flag in Chrome/Edge (Easiest for testing) 
You can explicitly tell your browser to treat your specific local HTTP URL as a secure context.

  • Open Chrome or Edge and navigate to:
    Code: [Select]
    chrome://flags/#unsafely-treat-insecure-origin-as-secure (or
    Code: [Select]
    edge://flags/#unsafely-treat-insecure-origin-as-secure)
  • Change the dropdown to Enabled.
  • In the text box provided, paste your local server's URL (e.g., http://your-local-server-ip:port).
  • Relaunch the browser. The clipboard API will now work seamlessly on that specific address.

Solution 2: Map the Remote Server to Localhost via SSH 
If you have SSH access to that server, you can map its web port directly to your machine. This tricks the browser into seeing it as a local site:

  • Run the following command in your local terminal:
    Code: [Select]
    ssh -L 8080:localhost:80 user@remote-server-ip
    • You can then access the site in your browser via http://localhost:8080. Because it uses the "localhost" hostname, the browser automatically unlocks the clipboard API.
    Moving forward, modern web security models require either a secure context (HTTPS/localhost) or explicit browser flag exceptions for applications utilizing clipboard, camera, geolocation, or crypto APIs.