Handle modifier keys (#74237)

This commit is contained in:
Kerry Gallagher 2020-08-04 17:13:32 +01:00 committed by GitHub
parent b42f64d1a2
commit 89dba39273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,6 +68,9 @@ export const useLinkProps = (
const onClick = useMemo(() => {
return (e: React.MouseEvent | React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => {
if (e.defaultPrevented || isModifiedEvent(e)) {
return;
}
e.preventDefault();
const navigate = () => {
@ -112,3 +115,6 @@ const validateParams = ({ app, pathname, hash, search }: LinkDescriptor) => {
);
}
};
const isModifiedEvent = (event: any) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);