-
Notifications
You must be signed in to change notification settings - Fork 44
Copy button for trigger link fails in HTTP context (Clipboard API unavailable) #236
Description
Summary
The "Copy" button for the trigger link does not work in certain environments.
Clicking the button throws a JavaScript error and the link is not copied to the clipboard.
Additionally, the trigger link is truncated in the UI, making manual copying impossible.
This issue appears to be related to the availability of the Clipboard API.
Steps to Reproduce
- Open an existing BackWPup job
- Click on "Frequency"
- Select "Triggered by link"
- A trigger link and "Copy" button are displayed
- Click the "Copy" button
Expected Behavior
- The full trigger link is copied to the clipboard
- Optional: user receives visual feedback (e.g. tooltip or message)
Actual Behavior
- Clicking the "Copy" button does nothing
- No UI feedback is shown
- The link is not copied
- The following error appears in the browser console:
Uncaught TypeError: Cannot read properties of undefined (reading 'writeText')
at HTMLDocument.<anonymous> (backwpup-admin.js:2535)
- The trigger link is truncated (
...) in the UI and cannot be copied manually
Root Cause (Analysis)
The issue occurs when the Clipboard API is not available.
In environments where the WordPress admin is served over HTTP (not HTTPS), navigator.clipboard is undefined because the Clipboard API is only available in secure contexts (HTTPS or localhost).
This explains why the issue cannot be reproduced in HTTPS environments.
Suggested Fix
Add a guard before calling the Clipboard API and optionally provide a fallback:
if (navigator.clipboard && navigator.clipboard.writeText) {
// Modern Clipboard API (secure contexts only)
navigator.clipboard.writeText(text);
} else {
// Clipboard API not available (e.g. HTTP or older browsers)
// Option 1: implement fallback (e.g. document.execCommand('copy'))
// Option 2: disable/hide copy button
// Option 3: show full link to allow manual copying
}
Additional UX Issue
The trigger link is truncated in the UI (...), which makes manual copying impossible.
Even if the truncation is intentional for layout reasons, users should still be able to:
- copy the full link manually, or
- access it via an alternative UI (e.g. input field)
Environment
- BackWPup: 5.6.6
- WordPress: 6.9.1
- Browser: Chrome 145, Firefox 148
References
Original WordPress support thread:
https://wordpress.org/support/topic/copy-button-for-the-trigger-link-does-not-work/
Notes
The issue has been confirmed in HTTP environments and acknowledged in the support thread.
It is likely not a browser limitation but expected behavior of the Clipboard API.
