Skip to content

Commit

Permalink
fix cmd + click for react
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Jan 15, 2025
1 parent f61d2f9 commit da7ec4c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/core/src/shouldIntercept.ts
Original file line number Diff line number Diff line change
@@ -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) ||
Expand Down

0 comments on commit da7ec4c

Please sign in to comment.