mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
[fix] Text onPress event propagation
The press event should not propagate. Fix #897
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user