mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-01 10:07:35 +00: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 isButtonRole = role === 'button';
|
||||||
const isDisabled = AccessibilityUtil.isDisabled(domProps);
|
const isDisabled = AccessibilityUtil.isDisabled(domProps);
|
||||||
|
const isLinkRole = role === 'link';
|
||||||
|
|
||||||
Object.keys(domProps).forEach(propName => {
|
Object.keys(domProps).forEach(propName => {
|
||||||
const prop = domProps[propName];
|
const prop = domProps[propName];
|
||||||
@@ -67,11 +68,11 @@ const adjustProps = domProps => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cancel click events if the responder system is being used. Click events
|
// Cancel click events if the responder system is being used on a link
|
||||||
// are not an expected part of the React Native API, and browsers dispatch
|
// element. Click events are not an expected part of the React Native API,
|
||||||
// click events that cannot otherwise be cancelled from preceding mouse
|
// and browsers dispatch click events that cannot otherwise be cancelled from
|
||||||
// events in the responder system.
|
// preceding mouse events in the responder system.
|
||||||
if (onResponderRelease) {
|
if (isLinkRole && onResponderRelease) {
|
||||||
domProps.onClick = function(e) {
|
domProps.onClick = function(e) {
|
||||||
if (!e.isDefaultPrevented() && !isModifiedEvent(e.nativeEvent) && !domProps.target) {
|
if (!e.isDefaultPrevented() && !isModifiedEvent(e.nativeEvent) && !domProps.target) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user