Skip to content

Commit

Permalink
Fix pointer event dispatch to nested text nodes
Browse files Browse the repository at this point in the history
Summary:
Noticed that we weren't receiving pointer events for nested Text spans when the new pointer events implementation was enabled.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D41496672

fbshipit-source-id: 9d0ed83d1bb5f42211ec655328035651f25fa471
  • Loading branch information
javache authored and facebook-github-bot committed Nov 29, 2022
1 parent 9c88dad commit 1b99473
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp
case MotionEvent.ACTION_CANCEL:
dispatchCancelEvent(eventState, motionEvent, eventDispatcher);
break;
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_EXIT:
// These are handled by HOVER_MOVE
break;
default:
FLog.w(
ReactConstants.TAG,
"Warning : Motion Event was ignored. Action=" + action + " Target=" + activeTargetTag);
"Motion Event was ignored. Action=" + action + " Target=" + activeTargetTag);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static List<ViewTarget> findTargetPathAndCoordinatesForTouch(
pathAccumulator = pathAccumulator.subList(firstReactAncestor, pathAccumulator.size());
}

int targetTag = getTouchTargetForView(reactTargetView, eventX, eventY);
int targetTag = getTouchTargetForView(reactTargetView, viewCoords[0], viewCoords[1]);
if (targetTag != reactTargetView.getId()) {
pathAccumulator.add(0, new ViewTarget(targetTag, (View) null));
}
Expand Down Expand Up @@ -396,11 +396,11 @@ && isTouchPointInView(eventCoords[0], eventCoords[1], view)
}
}

private static int getTouchTargetForView(View targetView, float eventX, float eventY) {
private static int getTouchTargetForView(View targetView, float viewX, float viewY) {
if (targetView instanceof ReactCompoundView) {
// Use coordinates relative to the view, which have been already computed by
// {@link #findTouchTargetView()}.
return ((ReactCompoundView) targetView).reactTagForTouch(eventX, eventY);
return ((ReactCompoundView) targetView).reactTagForTouch(viewX, viewY);
}
return targetView.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static String getW3CPointerType(final int toolType) {

public static boolean isListening(@Nullable View view, EVENT event) {
if (view == null) {
return false;
return true;
}

switch (event) {
Expand Down

0 comments on commit 1b99473

Please sign in to comment.