pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

Fix: Add fallback for clipboard.writeText #7314

Open heybran opened 1 week ago

heybran commented 1 week ago

Description

Copy button near field name previously was using navigator.clipboard.writeText, but I just found out that the API is only available for secure context: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText

So if developers are working locally on insecure context, copy button will fail. I believe I was working with https when I was adding this feature back then, so I didn't really catch the bug.

So I'm sending a fix PR to add a fallback to insecure context or old browsers.

Related GitHub issue(s)

7237

Testing instructions

  1. Spin up a local site without https
  2. Find the copy button
  3. Click the button, now the field name will be copied.

Screenshots / screencast

Changelog text for these changes

Bug: Copy button now works correctly in secure context. #7237 (@heybran)

PR checklist