Skip to content

Commit d1121c0

Browse files
authored
[react-interactions] Fix virtual click heuristic (#16915)
1 parent f553515 commit d1121c0

File tree

1 file changed

+7
-10
lines changed
  • packages/react-interactions/events/src/dom/shared

1 file changed

+7
-10
lines changed

packages/react-interactions/events/src/dom/shared/index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,13 @@ export function hasModifierKey(event: ReactDOMResponderEvent): boolean {
7171
);
7272
}
7373

74-
// Keyboards, Assitive Technologies, and element.click() all produce "virtual"
75-
// clicks that do not include coordinates and "detail" is always 0 (where
76-
// pointer clicks are > 0).
74+
// Keyboards, Assitive Technologies, and element.click() all produce a "virtual"
75+
// click event. This is a method of inferring such clicks. Every browser except
76+
// IE 11 only sets a zero value of "detail" for click events that are "virtual".
77+
// However, IE 11 uses a zero value for all click events. For IE 11 we rely on
78+
// the quirk that it produces click events that are of type PointerEvent, and
79+
// where only the "virtual" click lacks a pointerType field.
7780
export function isVirtualClick(event: ReactDOMResponderEvent): boolean {
7881
const nativeEvent: any = event.nativeEvent;
79-
return (
80-
nativeEvent.detail === 0 &&
81-
nativeEvent.screenX === 0 &&
82-
nativeEvent.screenY === 0 &&
83-
nativeEvent.clientX === 0 &&
84-
nativeEvent.clientY === 0
85-
);
82+
return nativeEvent.detail === 0 && !nativeEvent.pointerType;
8683
}

0 commit comments

Comments
 (0)