From da7ec4c9f5b20de0ac7efb8b41ba88191d97dba9 Mon Sep 17 00:00:00 2001 From: Joe Tannenbaum Date: Wed, 15 Jan 2025 16:53:51 -0500 Subject: [PATCH] fix cmd + click for react --- packages/core/src/shouldIntercept.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/core/src/shouldIntercept.ts b/packages/core/src/shouldIntercept.ts index c46b9b5c2..5502e07bc 100644 --- a/packages/core/src/shouldIntercept.ts +++ b/packages/core/src/shouldIntercept.ts @@ -1,9 +1,18 @@ -export default function shouldIntercept(event: MouseEvent | KeyboardEvent): boolean { +// The actual event passed to this function could be a native JavaScript event +// or a React synthetic event, so we are picking just the keys needed here (that +// are present in both types). + +export default function shouldIntercept( + event: Pick< + MouseEvent, + 'altKey' | 'ctrlKey' | 'defaultPrevented' | 'target' | 'currentTarget' | 'metaKey' | 'shiftKey' | 'button' + >, +): boolean { const isLink = (event.currentTarget as HTMLElement).tagName.toLowerCase() === 'a' + return !( (event.target && (event?.target as HTMLElement).isContentEditable) || event.defaultPrevented || - (isLink && event.which > 1) || (isLink && event.altKey) || (isLink && event.ctrlKey) || (isLink && event.metaKey) ||