[fix] Text onPress event propagation

The press event should not propagate.

Fix #897
This commit is contained in:
Nicolas Gallagher
2018-04-15 15:23:32 -07:00
parent cf2612663b
commit 1a225bc449

View File

@@ -62,7 +62,7 @@ class Text extends Component<*> {
if (onPress) {
otherProps.accessible = true;
otherProps.onClick = onPress;
otherProps.onClick = this._createPressHandler(onPress);
otherProps.onKeyDown = this._createEnterHandler(onPress);
}
@@ -89,6 +89,13 @@ class Text extends Component<*> {
}
};
}
_createPressHandler(fn) {
return e => {
e.stopPropagation();
fn && fn(e);
};
}
}
const styles = StyleSheet.create({