From 89dba3927333fc2f6b60573a1e173d966510ee41 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 4 Aug 2020 17:13:32 +0100 Subject: [PATCH] Handle modifier keys (#74237) --- x-pack/plugins/infra/public/hooks/use_link_props.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x-pack/plugins/infra/public/hooks/use_link_props.tsx b/x-pack/plugins/infra/public/hooks/use_link_props.tsx index dec8eaae56f4..710011d3bdf3 100644 --- a/x-pack/plugins/infra/public/hooks/use_link_props.tsx +++ b/x-pack/plugins/infra/public/hooks/use_link_props.tsx @@ -68,6 +68,9 @@ export const useLinkProps = ( const onClick = useMemo(() => { return (e: React.MouseEvent | React.MouseEvent) => { + 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);