Skip to content

Commit

Permalink
fix(frontend): copy on first hotkey stroke (#573)
Browse files Browse the repository at this point in the history
Fixes #437
  • Loading branch information
saihaj authored Jun 1, 2020
1 parent f0581fc commit 1b2ac37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/frontend/src/lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ export const useCopyToClipboard = () => {
const truncate = input => ( input.length > 30 ? `${input.substring( 0, 30 )}...` : input )

const { enqueueSnackbar } = useSnackbar()

return ( text, fallback = 'No text to copy' ) => {
if ( text ) copy( text )
if ( text ) {
// Double copying due to bug: https://github.com/sudodoki/copy-to-clipboard/issues/90
copy( text )
copy( text )
}

enqueueSnackbar(
text ? `Copied "${truncate( text )}" to clipboard` : fallback,
Expand Down

0 comments on commit 1b2ac37

Please sign in to comment.