Skip to content

Commit

Permalink
Change props for CopyToClipboard button since it's reused here.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Aug 29, 2024
1 parent 5305a81 commit e37ac17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion settings/src/components/backup-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function Setup( { setRegenerating, onSuccess } ) {
<CodeList codes={ backupCodes } />

<ButtonGroup>
<CopyToClipboardButton codes={ backupCodes } />
<CopyToClipboardButton contents={ backupCodes } />
<PrintButton />
<DownloadButton codes={ backupCodes } />
</ButtonGroup>
Expand Down
6 changes: 3 additions & 3 deletions settings/src/components/copy-to-clipboard-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import { useCallback, useState } from '@wordpress/element';
import { Button } from '@wordpress/components';

export default function CopyToClipboardButton( { codes, variant = 'secondary' } ) {
export default function CopyToClipboardButton( { contents, variant = 'secondary' } ) {
const [ copied, setCopied ] = useState( false );

const onClick = useCallback( () => {
navigator.clipboard.writeText( codes ).then( () => {
navigator.clipboard.writeText( contents ).then( () => {
setCopied( true );
setTimeout( () => setCopied( false ), 2000 );
} );
}, [ codes ] );
}, [ contents ] );

return (
<Button variant={ variant } onClick={ onClick }>
Expand Down
2 changes: 1 addition & 1 deletion settings/src/components/svn-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function SVNPassword() {
<code>{ generatedPassword || 'svn_*****************' }</code>
&nbsp;
{ generatedPassword && (
<CopyToClipboardButton variant="link" codes={ generatedPassword } />
<CopyToClipboardButton variant="link" contents={ generatedPassword } />

Check failure on line 94 in settings/src/components/svn-password.js

View workflow job for this annotation

GitHub Actions / All

Replace `·variant="link"·contents={·generatedPassword·}·` with `⏎↹↹↹↹↹↹↹↹↹variant="link"⏎↹↹↹↹↹↹↹↹↹contents={·generatedPassword·}⏎↹↹↹↹↹↹↹↹`
) }
{ userRecord.record.svn_password_created && (
<div className="wporg-2fa__svn-password_generated">
Expand Down

0 comments on commit e37ac17

Please sign in to comment.