[react-interactions] Refine virtual click detection for FF+JAWS/NVDA (#17422)
Dominic Gannaway committed
Nov 21, 2019 at 13:09 UTC
3fdfa231ad4bbe81516866dc9cd7ed5d18acf223
2 files changed
+9
packages/react-interactions/events/src/dom/PressLegacy.js
+5
@@ -489,6 +489,11 @@ function updateIsPressWithinResponderRegion(
489
// clicks (NVDA, Jaws, VoiceOver) do not have co-ords associated with the click
490
// event and "detail" is always 0 (where normal clicks are > 0)
491
function isScreenReaderVirtualClick(nativeEvent): boolean {
492
+ // JAWS/NVDA with Firefox.
493
+ if (nativeEvent.mozInputSource === 0 && nativeEvent.isTrusted) {
494
+ return true;
495
+ }
496
+ // Chrome
497
return (
498
nativeEvent.detail === 0 &&
499
nativeEvent.screenX === 0 &&
packages/react-interactions/events/src/dom/shared/index.js
+4
@@ -79,5 +79,9 @@ export function hasModifierKey(event: ReactDOMResponderEvent): boolean {
79
// where only the "virtual" click lacks a pointerType field.
80
export function isVirtualClick(event: ReactDOMResponderEvent): boolean {
81
const nativeEvent: any = event.nativeEvent;
82
+ // JAWS/NVDA with Firefox.
83
+ if (nativeEvent.mozInputSource === 0 && nativeEvent.isTrusted) {
84
+ return true;
85
+ }
86
return nativeEvent.detail === 0 && !nativeEvent.pointerType;
87
}