Skip to content

Commit

Permalink
[react-interactions] Refine virtual click detection for FF+JAWS/NVDA (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Nov 21, 2019
1 parent a7d07ff commit 3fdfa23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/react-interactions/events/src/dom/PressLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ function updateIsPressWithinResponderRegion(
// clicks (NVDA, Jaws, VoiceOver) do not have co-ords associated with the click
// event and "detail" is always 0 (where normal clicks are > 0)
function isScreenReaderVirtualClick(nativeEvent): boolean {
// JAWS/NVDA with Firefox.
if (nativeEvent.mozInputSource === 0 && nativeEvent.isTrusted) {
return true;
}
// Chrome
return (
nativeEvent.detail === 0 &&
nativeEvent.screenX === 0 &&
Expand Down
4 changes: 4 additions & 0 deletions packages/react-interactions/events/src/dom/shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@ export function hasModifierKey(event: ReactDOMResponderEvent): boolean {
// where only the "virtual" click lacks a pointerType field.
export function isVirtualClick(event: ReactDOMResponderEvent): boolean {
const nativeEvent: any = event.nativeEvent;
// JAWS/NVDA with Firefox.
if (nativeEvent.mozInputSource === 0 && nativeEvent.isTrusted) {
return true;
}
return nativeEvent.detail === 0 && !nativeEvent.pointerType;
}

0 comments on commit 3fdfa23

Please sign in to comment.