MCPcopy
hub / github.com/adobe/react-spectrum / isVirtualClick

Function isVirtualClick

packages/react-aria/src/utils/isVirtualEvent.ts:26–40  ·  view source on GitHub ↗
(event: MouseEvent | PointerEvent)

Source from the content-addressed store, hash-verified

24// where only the "virtual" click lacks a pointerType field.
25
26export function isVirtualClick(event: MouseEvent | PointerEvent): boolean {
27 // JAWS/NVDA with Firefox.
28 if ((event as PointerEvent).pointerType === '' && event.isTrusted) {
29 return true;
30 }
31
32 // Android TalkBack's detail value varies depending on the event listener providing the event so we have specific logic here instead
33 // If pointerType is defined, event is from a click listener. For events from mousedown listener, detail === 0 is a sufficient check
34 // to detect TalkBack virtual clicks.
35 if (isAndroid() && (event as PointerEvent).pointerType) {
36 return event.type === 'click' && event.buttons === 1;
37 }
38
39 return event.detail === 0 && !(event as PointerEvent).pointerType;
40}
41
42export function isVirtualPointerEvent(event: PointerEvent): boolean {
43 // If the pointer size is zero, then we assume it's from a screen reader.

Callers 5

onClickFunction · 0.90
usePressFunction · 0.90
handleClickEventFunction · 0.90
onClickFunction · 0.90
onClickMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected