The module currently relies exclusively on the Web Share API to trigger native sharing dialogs. However, this API is not supported in all browsers - especially on desktop (e.g., Firefox, Safari on macOS). As a result, the share button silently fails in unsupported environments, leading to poor user experience.
Implement a graceful fallback mechanism for browsers that do not support navigator.share. Suggested behavior if navigator.share is unavailable:
- Use navigator.clipboard.writeText() to copy the current page URL.
- Show a confirmation message (e.g., alert() or modal): “Link copied to clipboard.”
- If clipboard API is also unavailable, fall back to prompt() with the URL pre-filled.
This logic can be added to the module’s JavaScript file inside a Drupal.behaviors block using once() to avoid duplicate bindings.
if (navigator.share) {
navigator.share(shareData).catch(console.error);
} else if (navigator.clipboard) {
navigator.clipboard.writeText(shareData.url).then(() => {
alert('Link copied to clipboard!');
}).catch(() => {
prompt('Copy this link:', shareData.url);
});
} else {
prompt('Copy this link:', shareData.url);
}- Improves UX for users on unsupported browsers.
- Makes the module more robust and production-ready.
- Aligns with progressive enhancement principles.
Needs review
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.