mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-27 21:07:26 +08:00
[fix] only call preventDefault for clicks on links
The previous incarnation of this fix would cancel clicks that bubble up to elements like ScrollViews, with undesired impact on child element events. Instead, limit the hack to elements with accessibilityRole=link. Fix #985
This commit is contained in:
@@ -50,6 +50,7 @@ const adjustProps = domProps => {
|
||||
|
||||
const isButtonRole = role === 'button';
|
||||
const isDisabled = AccessibilityUtil.isDisabled(domProps);
|
||||
const isLinkRole = role === 'link';
|
||||
|
||||
Object.keys(domProps).forEach(propName => {
|
||||
const prop = domProps[propName];
|
||||
@@ -67,11 +68,11 @@ const adjustProps = domProps => {
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel click events if the responder system is being used. Click events
|
||||
// are not an expected part of the React Native API, and browsers dispatch
|
||||
// click events that cannot otherwise be cancelled from preceding mouse
|
||||
// events in the responder system.
|
||||
if (onResponderRelease) {
|
||||
// Cancel click events if the responder system is being used on a link
|
||||
// element. Click events are not an expected part of the React Native API,
|
||||
// and browsers dispatch click events that cannot otherwise be cancelled from
|
||||
// preceding mouse events in the responder system.
|
||||
if (isLinkRole && onResponderRelease) {
|
||||
domProps.onClick = function(e) {
|
||||
if (!e.isDefaultPrevented() && !isModifiedEvent(e.nativeEvent) && !domProps.target) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user