Copy actions show success even when clipboard write fails
- Lenguaje dominante
- TypeScript
- Estrellas
- 5
- Forks
- 28
- Merge medio
- 9 h 50 min
- PR fusionados (30 d)
- 123
Descripción
### Summary
The shared `useCopyToClipboard` hook marks copy actions as successful immediately after calling `navigator.clipboard.writeText(...)`, without waiting for the returned promise to resolve or handling rejections.
### Why this matters
Clipboard writes can reject in real wallet environments, for example when the extension popup loses document focus, when a mobile/webview environment does not support the async Clipboard API, or when the permission is denied. In those cases the UI can still show the success state even though nothing was copied.
This hook backs sensitive copy flows such as seed phrase / secret reveal screens as well as address copy actions, so a false success state can make users believe they have copied recovery material or an address when the clipboard still contains old content.
### Code path
`src/lib/ui/useCopyToClipboard.ts` currently calls:
```ts
navigator.clipboard.writeText(textarea.value);
setCopied(true);
```
Because `writeText()` returns a `Promise`, a rejection leaves the failure unhandled while `copied` has already been set to `true`.
### Expected behavior
The hook should only set `copied=true` after `writeText()` resolves, and should leave/reset the copied state on rejection.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.