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',
|
text: 'Découvrez cette version sur Konstitisyon.la',
|
||||||
url
|
url
|
||||||
})
|
})
|
||||||
|
setSnackbar({
|
||||||
|
open: true,
|
||||||
|
message: 'Version partagée',
|
||||||
|
severity: 'success'
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Fallback: copy URL to clipboard
|
// Fallback: copy URL to clipboard
|
||||||
await navigator.clipboard.writeText(url)
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
// Could show a toast notification here
|
await navigator.clipboard.writeText(url)
|
||||||
|
} 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) {
|
} catch (error) {
|
||||||
console.error('Failed to share:', 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