Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components: ExternalLink onClick event handler is not working #45212

Closed
Initsogar opened this issue Oct 21, 2022 · 0 comments · Fixed by #45214
Closed

Components: ExternalLink onClick event handler is not working #45212

Initsogar opened this issue Oct 21, 2022 · 0 comments · Fixed by #45214
Assignees

Comments

@Initsogar
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants