Skip to content

Commit

Permalink
Handle modifier keys (#74237) (#74270)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry350 authored Aug 4, 2020
1 parent cdfcd53 commit 49ffd41
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x-pack/plugins/infra/public/hooks/use_link_props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -112,3 +115,6 @@ const validateParams = ({ app, pathname, hash, search }: LinkDescriptor) => {
);
}
};

const isModifiedEvent = (event: any) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);

0 comments on commit 49ffd41

Please sign in to comment.