Anyone encounter wixWindow.copyToClipboard not working in Mobile Browser?
I implement click button to copy to clipboard, it works on PC Browser, but when I test on mobile browser, it just show popup and with the text that supposed to copy, with OK & Cancel. When click OK, the popup closed. Nothing was copied, I can’t paste anything from it.
This is not your fault. This is a known issue happened a long time ago. @Yiserel, can you pass this to the components team? I think it is the iOS blocking the copy to clipboard access
Issues with wixWindow.copyToClipboard on Safari iOS – Seeking Solutions
I’m experiencing problems with the Wix “copyToClipboard()” function (Copy To Clipboard | Velo) on my Wix website when using Safari on iOS devices. While the function works perfectly on desktop browsers like Chrome and Edge, it doesn’t function correctly on Safari for iOS. Users are either seeing a Copy to clipboard dialog or the copying fails silently, which negatively impacts the user experience.
Attempts to Resolve:
Using navigator.clipboard.writeText:
Not viable because direct access to navigator.clipboard is restricted in the Wix Velo environment.
Using document.execCommand('copy') within an HTML Component:
Direct access to the global document object is not allowed in Wix Velo.
Embedding HTML components (iframes) doesn’t solve the issue due to security restrictions in Safari.
External NPM Packages like copy-to-clipboard or clipboard-js:
These packages either don’t function correctly within the Wix environment or don’t resolve the issue on Safari iOS.
Alternative Approaches:
Automatically selecting the promo code in an input field to facilitate manual copying. The “select” function is not working.
Possible Causes:
Safari iOS Security Restrictions:
Strict security policies prevent automatic clipboard copying without direct user interaction.
Even with user interaction, Safari may display a confirmation dialog that cannot be suppressed.
Wix Velo Limitations:
Restricted access to global objects like document and navigator.clipboard.
This limits the ability to implement alternative copying methods.
Request for Assistance:
Is there a way to modify or extend the wixWindow.copyToClipboard function to work reliably on Safari iOS without triggering a confirmation dialog?
Could Wix update the internal implementation of copyToClipboard to utilize the latest clipboard APIs supported by Safari on iOS, or provide alternative methods compatible with Apple’s security policies?
Are there any known workarounds or best practices to overcome this issue without degrading the user experience?
Many modern websites use the navigator.clipboard.writeText() API to reliably copy text to the clipboard, which works seamlessly across browsers, including Safari on iOS, as long as it’s triggered by a user interaction like a button click. I would like to request the implementation of support for the modern Clipboard API (navigator.clipboard.writeText) in Wix Velo.
Goal:
I aim to provide a seamless experience where users can copy a promo code by clicking a button, across all major browsers and devices, including Safari on iOS.
Any insights or suggestions would be greatly appreciated.