Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add fallback for clipboard.writeText #7314

Conversation

heybran
Copy link
Contributor

@heybran heybran commented Jun 21, 2024

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

@sc0ttkclark sc0ttkclark changed the base branch from main to release/3.2.7 August 27, 2024 01:39
@sc0ttkclark sc0ttkclark merged commit b4f492c into pods-framework:release/3.2.7 Aug 27, 2024
1 of 3 checks passed
Copy link

what-the-diff bot commented Aug 27, 2024

PR Summary

  • Updated Dependencies Version in JSON file
    The version value of dependencies has been updated in pods-blocks-api.min.asset.json under ui/js/blocks.

  • Addition of New Copy Function
    A new function named copyToClipboard has been added in copy-button.js under ui/js/dfv/src/components/. This function is designed to assist in copying text to clipboard. It checks and utilizes any available clipboard.writeText method and if it is not available, it resorts to creating an input element and applying the document.execCommand('copy') method. The CopyButton component has been updated in order to utilize this new copyToClipboard function.

  • Modifications in CSS Design
    Changes have been made in the CSS of the pods-field_copy-button class found within copy-button.scss under ui/js/dfv/src/components/. This amendment includes the addition of padding and modification of the display property to inline-flex which will influence the visual presentation of the copy button on the user interface. This adjustment aims to improve user experience and interaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants