fix: ajouté feedback visuel pour bouton partage en-tête
- Notifications snackbar pour partage natif et copie presse-papier - Gestion erreurs avec messages appropriés - Fallback complet pour navigateurs plus anciens
This commit is contained in:
@@ -108,13 +108,47 @@ export default function VersionPage({session, versionId, viewMode}) {
|
||||
text: 'Découvrez cette version sur Konstitisyon.la',
|
||||
url
|
||||
})
|
||||
setSnackbar({
|
||||
open: true,
|
||||
message: 'Version partagée',
|
||||
severity: 'success'
|
||||
})
|
||||
} else {
|
||||
// Fallback: copy URL to clipboard
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(url)
|
||||
// Could show a toast notification here
|
||||
} else {
|
||||
// Fallback for older browsers
|
||||
const textArea = document.createElement('textarea')
|
||||
textArea.value = url
|
||||
textArea.style.position = 'fixed'
|
||||
textArea.style.left = '-999999px'
|
||||
textArea.style.top = '-999999px'
|
||||
document.body.append(textArea)
|
||||
textArea.focus()
|
||||
textArea.select()
|
||||
|
||||
const result = document.execCommand('copy')
|
||||
textArea.remove()
|
||||
|
||||
if (!result) {
|
||||
throw new Error('Copy command failed')
|
||||
}
|
||||
}
|
||||
|
||||
setSnackbar({
|
||||
open: true,
|
||||
message: 'Lien copié dans le presse-papier',
|
||||
severity: 'success'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to share:', error)
|
||||
setSnackbar({
|
||||
open: true,
|
||||
message: 'Impossible de partager cette version',
|
||||
severity: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user