|
33 | 33 | import com.facebook.react.bridge.ReadableType; |
34 | 34 | import com.facebook.react.common.MapBuilder; |
35 | 35 | import com.facebook.react.common.ReactConstants; |
| 36 | +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags; |
36 | 37 | import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole; |
37 | 38 | import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role; |
38 | 39 | import com.facebook.react.uimanager.annotations.ReactProp; |
@@ -70,6 +71,8 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode |
70 | 71 | private static final String STATE_EXPANDED = "expanded"; |
71 | 72 | private static final String STATE_MIXED = "mixed"; |
72 | 73 |
|
| 74 | + private static final View.OnTouchListener NOOP_LISTENER = (v, event) -> false; |
| 75 | + |
73 | 76 | public BaseViewManager() { |
74 | 77 | super(null); |
75 | 78 | } |
@@ -165,6 +168,7 @@ public BaseViewManager(@Nullable ReactApplicationContext reactContext) { |
165 | 168 | // NOTE: setClickable MUST be called AFTER setOnClickListener because |
166 | 169 | // the latter has the side effect of setting isClickable=true on some views! |
167 | 170 | view.setOnClickListener(null); |
| 171 | + setInteractable(view, false); |
168 | 172 | view.setClickable(false); |
169 | 173 | view.setFocusable(false); |
170 | 174 | view.setFocusableInTouchMode(false); |
@@ -980,7 +984,24 @@ public void setMoveShouldSetResponderCapture(@NonNull T view, boolean value) { |
980 | 984 |
|
981 | 985 | @ReactProp(name = "onStartShouldSetResponder") |
982 | 986 | public void setStartShouldSetResponder(@NonNull T view, boolean value) { |
983 | | - // no-op, handled by JSResponder |
| 987 | + // Touch handled by the JSResponder system, but listener is needed to indicate interactability. |
| 988 | + setInteractable(view, value); |
| 989 | + } |
| 990 | + |
| 991 | + private static void setInteractable(@NonNull View view, boolean interactable) { |
| 992 | + if (!ReactNativeFeatureFlags.enableInteractableResponderViews()) { |
| 993 | + return; |
| 994 | + } |
| 995 | + boolean noopListener = view.getTag(R.id.noop_touch_listener) != null; |
| 996 | + if (interactable) { |
| 997 | + if (!noopListener) { |
| 998 | + view.setOnTouchListener(NOOP_LISTENER); |
| 999 | + view.setTag(R.id.noop_touch_listener, Boolean.TRUE); |
| 1000 | + } |
| 1001 | + } else if (noopListener) { |
| 1002 | + view.setOnTouchListener(null); |
| 1003 | + view.setTag(R.id.noop_touch_listener, null); |
| 1004 | + } |
984 | 1005 | } |
985 | 1006 |
|
986 | 1007 | @ReactProp(name = "onStartShouldSetResponderCapture") |
|
0 commit comments