Description
We are using ExternalLink on multiple instances in Jetpack monorepo, using the onClick event handler to track clicks. After a recent change implemented, any code passed to onClick prop is being ignored by this component.
This is related to a recent change implemented for validating anchor links in #42259.
Step-by-step reproduction instructions
You can reproduce the bug by adding an onClick event handler to ExternalLink. After clicking the link, you will notice it is not calling doSomething function.
import { ExternalLink } from '@wordpress/components';
import { useCallback } from '@wordpress/element';
const MyExternalLink = () => {
const doSomething = useCallback( () => {
console.log( 'ExternalLink clicked!' );
}, [] );
return (
<ExternalLink href="https://wordpress.org" onClick={ doSomething }>
WordPress.org
</ExternalLink>
);
);
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Description
We are using ExternalLink on multiple instances in Jetpack monorepo, using the onClick event handler to track clicks. After a recent change implemented, any code passed to onClick prop is being ignored by this component.
This is related to a recent change implemented for validating anchor links in #42259.
Step-by-step reproduction instructions
You can reproduce the bug by adding an
onClickevent handler toExternalLink. After clicking the link, you will notice it is not callingdoSomethingfunction.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes