From 52e5d41518fe49100da2b85a3dcd5b9cabffb584 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sun, 17 Sep 2017 12:48:10 -0700 Subject: [PATCH] [fix] keyboard interaction with Touchable as link Fix #643 Close #645 --- src/components/Touchable/Touchable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Touchable/Touchable.js b/src/components/Touchable/Touchable.js index 5f663925..cee3b6d4 100644 --- a/src/components/Touchable/Touchable.js +++ b/src/components/Touchable/Touchable.js @@ -12,6 +12,7 @@ * @flow */ +import AccessibilityUtil from '../../modules/AccessibilityUtil'; import BoundingDimensions from './BoundingDimensions'; import findNodeHandle from '../../modules/findNodeHandle'; import normalizeColor from 'normalize-css-color'; @@ -819,7 +820,11 @@ const TouchableMixin = { } } e.stopPropagation(); - e.preventDefault(); + // prevent the default behaviour unless the Touchable functions as a link + // and Enter is pressed + if (!(which === ENTER && AccessibilityUtil.propsToAriaRole(this.props) === 'link')) { + e.preventDefault(); + } } } };