Skip to content

Commit

Permalink
Modify ExternalLink component to forwards its ref
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jul 16, 2018
1 parent b406e4d commit 39f82fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/external-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { compact, uniq } from 'lodash';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { forwardRef } from '@wordpress/element';

/**
* Internal dependencies
*/
import Dashicon from '../dashicon';
import './style.scss';

function ExternalLink( { href, children, className, rel = '', ...additionalProps } ) {
export function ExternalLink( { href, children, className, rel = '', ...additionalProps }, ref ) {
rel = uniq( compact( [
...rel.split( ' ' ),
'external',
Expand All @@ -24,7 +25,7 @@ function ExternalLink( { href, children, className, rel = '', ...additionalProps
] ) ).join( ' ' );
const classes = classnames( 'components-external-link', className );
return (
<a { ...additionalProps } className={ classes } href={ href } target="_blank" rel={ rel }>
<a { ...additionalProps } className={ classes } href={ href } target="_blank" rel={ rel } ref={ ref }>
{ children }
<span className="screen-reader-text">
{
Expand All @@ -37,4 +38,4 @@ function ExternalLink( { href, children, className, rel = '', ...additionalProps
);
}

export default ExternalLink;
export default forwardRef( ExternalLink );

0 comments on commit 39f82fe

Please sign in to comment.